Pre filled message content - Possible?

Started by Gobo, September 30, 2006, 10:17:31 AM

Previous topic - Next topic

Gobo

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:



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

If yes then how?

Thanks,
Aku

codenaught

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>';
Dev Consultant
Former SMF Doc Coordinator

Gobo


Gobo

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

codenaught

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.
Dev Consultant
Former SMF Doc Coordinator

Gobo

#5
works great!!!

Thank you so much!!

just one more final question:

how can i adapt this to work for multiple boards?

codenaught

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.
Dev Consultant
Former SMF Doc Coordinator

Gobo

ooohhh man i love u!!

thanks so much

PS: I think this would be a good topic in tips & tricks board :D

codenaught

Glad you like it. :)

Fair enough. Moved to tips and tricks. :)
Dev Consultant
Former SMF Doc Coordinator

Corrupter

#9
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.

sweetdeath

How can it be avoid that the pre filled message will be add again if somebody edit the first post?

Gobo

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 :)

L.G.S

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?
FREE and LIVE World Cup + Premier League football streams:

www.gamesandgoals.com


Gobo

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

L.G.S

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..
FREE and LIVE World Cup + Premier League football streams:

www.gamesandgoals.com


eleven0


codenaught

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.
Dev Consultant
Former SMF Doc Coordinator

eleven0

What would I change to have this on multiple boards with different pre-filled content on each?

Rumbaar

"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

franklinrony

http://twitter.com/franklinrony

Entra y aprende a ser un webmaster
www.sv-blog.com
--Si pides ayuda al menos agradece el soporte recibido----

aldenddlove


forummaker

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.


Carlos Gandra

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 :)
Carlos Gandra
Mundo dos Animais

Minare

I did it, but there seems no change , as if I didn't change anything =)

ThorstenE

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'])

Nathaniel

SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

forummaker


Yesdel

#28
...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>';
}


forummaker

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.

Jessikard

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


Jessikard

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 ?

Rumbaar

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.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

forummaker

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.

Jessikard

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 ???

H

Jessikard, do you still need help with this? :)
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Jessikard

thx...
we managed it with a new BBcode-button which filled in the needed text

jhaagmans

This is now easy to do in 1.1.10 using the Post Template Mod. Good luck!

luismanson

would this work on RC2? im looking for an option to enable a template on some boards kinda wikipedia templates

Advertisement: