Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Gobo on September 30, 2006, 10:17:31 AM

Title: Pre filled message content - Possible?
Post by: Gobo on September 30, 2006, 10:17:31 AM
Hi

If you visit dynamicdrive forums you will notice that on their support board when you compose a message the message body automatically contains some text as shown below:

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg87.imageshack.us%2Fimg87%2F83%2Fawc1kh9.jpg&hash=d875b2db1828cd551fdb006e1417c27900089a27)

Is this possible to do on SMF as well only for specific boards?

If yes then how?

Thanks,
Aku
Title: Re: Pre filled message content - Possible?
Post by: codenaught on September 30, 2006, 10:40:54 AM
Themes/theme_name/Post.template.php:

// Finally the most important bit - the actual text box to write in!
echo '
<tr>
<td valign="top" align="right"></td>
<td>
<textarea class="editor" name="', $context['post_box_name'], '" rows="', $context['post_box_rows'], '" cols="', $context['post_box_columns'], '" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="', $context['tabindex']++, '"', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? ' style="border: 1px solid red;"' : '', '>', $message, '</textarea>
</td>
</tr>';


Change to something like (Changing the needed info added to that code to what you want):

// Finally the most important bit - the actual text box to write in!
echo '
<tr>
<td valign="top" align="right"></td>
<td>
<textarea class="editor" name="', $context['post_box_name'], '" rows="', $context['post_box_rows'], '" cols="', $context['post_box_columns'], '" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="', $context['tabindex']++, '"', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? ' style="border: 1px solid red;"' : '', '>', $context['current_board'] == 1 ? '1) Script Title:
2) More Stuff:' : '' .' ', $message, '</textarea>
</td>
</tr>';
Title: Re: Pre filled message content - Possible?
Post by: Gobo on September 30, 2006, 11:25:07 AM
thanks ill try it out today :D
Title: Re: Pre filled message content - Possible?
Post by: Gobo on September 30, 2006, 12:41:43 PM
ok tested and it works but 1 issue:

all replies contain the same prefilled content

is it possible to only specify it for the 1st post?

thanks
Title: Re: Pre filled message content - Possible?
Post by: codenaught on September 30, 2006, 01:01:26 PM
Try this then:

// Finally the most important bit - the actual text box to write in!
echo '
<tr>
<td valign="top" align="right"></td>
<td>
<textarea class="editor" name="', $context['post_box_name'], '" rows="', $context['post_box_rows'], '" cols="', $context['post_box_columns'], '" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="', $context['tabindex']++, '"', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? ' style="border: 1px solid red;"' : '', '>', $context['current_board'] == 1 && $context['is_first_post'] ? '1) Script Title:
2) More Stuff:' : '' .' ', $message, '</textarea>
</td>
</tr>';


Haven't been able to test it but I imagine it should work.
Title: Re: Pre filled message content - Possible?
Post by: Gobo on September 30, 2006, 01:58:04 PM
works great!!!

Thank you so much!!

just one more final question:

how can i adapt this to work for multiple boards?
Title: Re: Pre filled message content - Possible?
Post by: codenaught on October 01, 2006, 12:36:30 PM
Change the bit of code to:

$which_boards = array(1,2,3);

// Finally the most important bit - the actual text box to write in!
echo '
<tr>
<td valign="top" align="right"></td>
<td>
<textarea class="editor" name="', $context['post_box_name'], '" rows="', $context['post_box_rows'], '" cols="', $context['post_box_columns'], '" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="', $context['tabindex']++, '"', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? ' style="border: 1px solid red;"' : '', '>', in_array($context['current_board'],$which_boards) && $context['is_first_post'] ? '1) Script Title:
2) More Stuff:' : '' .' ', $message, '</textarea>
</td>
</tr>';
}


Adding the board ids you want to the $which_boards array at the top of the code.
Title: Re: Pre filled message content - Possible?
Post by: Gobo on October 01, 2006, 08:50:51 PM
ooohhh man i love u!!

thanks so much

PS: I think this would be a good topic in tips & tricks board :D
Title: Re: Pre filled message content - Possible?
Post by: codenaught on October 01, 2006, 09:03:02 PM
Glad you like it. :)

Fair enough. Moved to tips and tricks. :)
Title: Re: Pre filled message content - Possible?
Post by: Corrupter on November 05, 2006, 04:54:58 PM
Now what about doing this for posts made using the post event function under the calendar, i would imagine it has something to do with making those additions up under the // Are you posting a calendar event? section but i cant figure out where to put it or even if its worded the same.

i tried tinkering with board id's but i dont get it to work.

Nevermind i must of mistyped the board id for the calendar or didnt refresh before, its working now with board id of 0 for the calendar posting.

Although im sure it would be a neat trick to add it to the calendar event? section.
Title: Re: Pre filled message content - Possible?
Post by: sweetdeath on November 30, 2006, 04:25:19 AM
How can it be avoid that the pre filled message will be add again if somebody edit the first post?
Title: Re: Pre filled message content - Possible?
Post by: Gobo on November 30, 2006, 05:14:43 AM
oh by the way i forgot to say now there is a whole mod been developed by Thurnok down at Tiny Portal for this using Database to store entries for multiple boards
check it out below:
http://www.tinyportal.net/smf/index.php?topic=9419.0

you can post for support questions regarding that in that thread over at tiny portal if you want :)
Title: Re: Pre filled message content - Possible?
Post by: L.G.S on December 04, 2006, 07:18:52 AM
Sorry if it's not supposed to be in here, but it seems it should:

How would I have an image in the background of quick reply and normal reply boxes?
Title: Re: Pre filled message content - Possible?
Post by: Gobo on December 04, 2006, 07:20:59 AM
yup its definately not supposed to be in here

u would have better luck at getting an answer if u start a new thread and title it something like "using a background image for reply boxes - possible?"

maybe someone has the answer
Title: Re: Pre filled message content - Possible?
Post by: L.G.S on December 04, 2006, 08:51:46 AM
Yeah I know what to put in the topic.. I just put it in here because it was still related to filling the post boxes up before a post..
Title: Re: Pre filled message content - Possible?
Post by: eleven0 on October 11, 2007, 03:46:43 PM
Does version matter?
Title: Re: Pre filled message content - Possible?
Post by: codenaught on November 13, 2007, 12:53:20 AM
Quote from: Eleven0 on October 11, 2007, 03:46:43 PM
Does version matter?
The code to search for appears to be the same in the latest version, so it should still work with SMF 1.1.4.
Title: Re: Pre filled message content - Possible?
Post by: eleven0 on January 25, 2008, 11:18:04 AM
What would I change to have this on multiple boards with different pre-filled content on each?
Title: Re: Pre filled message content - Possible?
Post by: Rumbaar on February 16, 2008, 09:04:49 PM
Did you check out the alternate version eleven0?
http://www.tinyportal.net/index.php?topic=9419.0
Title: Re: Pre filled message content - Possible?
Post by: franklinrony on June 11, 2008, 01:11:23 PM
thank you very very very much,
Title: Re: Pre filled message content - Possible?
Post by: aldenddlove on June 12, 2008, 06:02:55 AM
Thurnok down for this using Database.
Title: Re: Pre filled message content - Possible?
Post by: forummaker on June 21, 2008, 08:55:49 AM
Quote from: sweetdeath on November 30, 2006, 04:25:19 AM
How can it be avoid that the pre filled message will be add again if somebody edit the first post?
I can't find the answer to this question.
If someone modifies their post, it re-populates the pre filled message. How can this be avoided? Thanks.
Title: Re: Pre filled message content - Possible?
Post by: Nibogo on June 21, 2008, 09:08:00 AM
thank you , really a very nice modification
Title: Re: Pre filled message content - Possible?
Post by: Carlos Gandra on July 01, 2008, 04:36:39 PM
Quote from: forummaker on June 21, 2008, 08:55:49 AM
Quote from: sweetdeath on November 30, 2006, 04:25:19 AM
How can it be avoid that the pre filled message will be add again if somebody edit the first post?
I can't find the answer to this question.
If someone modifies their post, it re-populates the pre filled message. How can this be avoided? Thanks.

Same question :)
Title: Re: Pre filled message content - Possible?
Post by: Minare on July 02, 2008, 06:57:35 AM
I did it, but there seems no change , as if I didn't change anything =)
Title: Re: Pre filled message content - Possible?
Post by: ThorstenE on July 03, 2008, 05:38:59 AM
Quote from: sweetdeath on November 30, 2006, 04:25:19 AM
How can it be avoid that the pre filled message will be add again if somebody edit the first post?
can be fixed by replacing
$context['is_first_post']
to
empty($context['current_topic'])
Title: Re: Pre filled message content - Possible?
Post by: Nathaniel on July 09, 2008, 11:53:53 PM
This mod could also perform a similar function: ;D
http://custom.simplemachines.org/mods/index.php?mod=1279
Title: Re: Pre filled message content - Possible?
Post by: forummaker on August 14, 2008, 07:27:23 PM
Thanks TE! Worked like a charm.
Title: Re: Pre filled message content - Possible?
Post by: Yesdel on February 18, 2009, 04:28:27 PM
...to tweak the code bit...

If the user forget to type in something into the subject field, or another posting error occurs, then the "prefill text" will appear twice or more in the text area.

This code below will prevent that:

$which_boards = array(1,2,3);

// Finally the most important bit - the actual text box to write in!
echo '
<tr>
<td valign="top" align="right"></td>
<td>
<textarea class="editor" name="', $context['post_box_name'], '" rows="', $context['post_box_rows'], '" cols="', $context['post_box_columns'], '" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="', $context['tabindex']++, '"', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? ' style="border: 1px solid red;"' : '', '>', in_array($context['current_board'],$which_boards) && empty($context['current_topic']) && empty($context['post_error']) ? '1) Script Title:
2) More Stuff:' : '' .'', $message, '</textarea>
</td>
</tr>';
}

Title: Re: Pre filled message content - Possible?
Post by: forummaker on April 18, 2009, 10:43:38 AM
I just added this last night and I thought everything was working with this until I tried to use the PM system for the first time today. For some reason it populated the pre-filled text in the body of the message. Here's the code I'm using.
I thought the calendar board is "0", is it not?

$which_boards = array(0,22);

   // Finally the most important bit - the actual text box to write in!
   echo '
         <tr>
            <td valign="top" align="right"></td>
            <td>
               <textarea class="editor" name="', $context['post_box_name'], '" rows="', $context['post_box_rows'], '" cols="', $context['post_box_columns'], '" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="', $context['tabindex']++, '"', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? ' style="border: 1px solid red;"' : '', '>', in_array($context['current_board'],$which_boards) && empty($context['current_topic']) && empty($context['post_error']) ? 'Here is more information about this event.

Name of Event:

Location:

Date:

Time:

Description:' : '' .' ', $message, '</textarea>
            </td>
         </tr>';
}

Any suggestions to fix would be greatly appreciated.
Title: Re: Pre filled message content - Possible?
Post by: Jessikard on April 28, 2009, 12:34:15 PM
we wanna use it, but there´s a mod-code in these lines

// Finally the most important bit - the actual text box to write in!
echo '
<tr>';
if ($context['post_box_switch'] == 'off' && $context['post_box_message'] != '' && $context['current_action'] == 'post')
echo '
<td class="tborder" width="18%" height="', $context['post_box_rows'], '" valign="top" align="left" style="overflow: auto; padding: 4px; border: 1px solid red;">
', parse_bbc($context['post_box_message']), '</td>';
else
echo '<td width="18%"></td>';
echo '
<td colspan="2">
<textarea style="width: ', $context['post_box_columns'], ';" name="', $context['post_box_name'], '" rows="', $context['post_box_rows'], '" cols="', $context['post_box_columns'], '" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="', $context['tabindex']++, '"', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? ' style="border: 1px solid red;"' : '', '>', $message, '</textarea>
</td>
</tr>';


i need help to run this "mod" with our codelines - working with two boards for our support-area

Title: Re: Pre filled message content - Possible?
Post by: Jessikard on April 28, 2009, 02:58:59 PM
okay - i solved it - but now ther´s an error

Quote8: Undefined index: current_board
Datei: /var/www/web0/html/forum/Themes/default/Post.template.php (send sub template - eval?)

how can i fix it ?
Title: Re: Pre filled message content - Possible?
Post by: Rumbaar on May 05, 2009, 07:34:30 PM
As for Calendar 'board' ID, I wasn't aware it had one.  Unless you mean the one that actual posts are linked too/made.  Then it would be the one you've defined as the default board for new event related posts.

It looks like it's call that code when it's not inside a board, hence the current_board information isn't populated.
Title: Re: Pre filled message content - Possible?
Post by: forummaker on May 05, 2009, 10:08:43 PM
Thanks for the reply rumbaar. I've read your reply several times and I'm not sure what your saying.
I'll explain my issue a little better.
I would like this to populate when someone clicks the "post event" link from the calendar.
It only populates if I use the "0" board for use with "post event". The "22" is the board if someone posts a reply from the forum, then it will populate there.
Now the problem is when I use the PM system it populates there, when creating a new message to send to someone.
Maybe I didn't need to explain further, but trying to get down to the nitty-gritty with this issue.
Thanks for any further help with this.
Title: Re: Pre filled message content - Possible?
Post by: Jessikard on May 17, 2009, 07:01:40 PM
Quote from: Rumbaar on May 05, 2009, 07:34:30 PM
It looks like it's call that code when it's not inside a board, hence the current_board information isn't populated.

can you tell me please where and how i have to include a code to be out of this error ???
Title: Re: Pre filled message content - Possible?
Post by: H on July 06, 2009, 07:20:05 PM
Jessikard, do you still need help with this? :)
Title: Re: Pre filled message content - Possible?
Post by: Jessikard on July 07, 2009, 05:16:10 PM
thx...
we managed it with a new BBcode-button which filled in the needed text
Title: Re: Pre filled message content - Possible?
Post by: jhaagmans on August 17, 2009, 11:06:42 AM
This is now easy to do in 1.1.10 using the Post Template Mod (http://www.simplemachines.org/community/index.php?topic=331419.0). Good luck!
Title: Re: Pre filled message content - Possible?
Post by: luismanson on February 22, 2010, 08:33:27 PM
would this work on RC2? im looking for an option to enable a template on some boards kinda wikipedia templates