MyBB Community Forums

Full Version: How to make a default PM subject.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I've been getting annoyed with how you must place something in the PM subject field in order to be sent so I figured out a small fix for the issue. This short tutorials will show you how to have a default subject in your PM subject field instead of having to be redirected back to the editor when you forget to type in a subject...

1. Navigate to your theme's templates > PM Templates > private_send template.

2. Find this segment of code:
<td class="trow1"><input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="3" /></td>

3. Replace that segment of code with this:
Quote:<td class="trow1"><input type="text" class="textbox" name="No Subject" size="40" maxlength="85" value="No Subject" onfocus="if(this.value == 'No Subject') { this.value = ''; }" tabindex="3" /></td>

This will make your subject field, "No Subject" by default and when you click it, the text is erased so you can type your own subject if needed.

If you want to make the default text different just change the red highlighted text Big Grin
If you change the name of the input box it's not going to work when you send it is it...

"subject" => $mybb->input['subject']

Doing this all you'll get is empty subjects for all PMs... don't change the name of the input box, don't see why that's necessary.
Hmm ok well how else can it be done?
You can't really, not like that. value="{$subject}" has to stay as it is because this template is used when you reply and forward too, so if you change that, the subject won't get carried across between PMs. Doing it your way the best you could probably do it is this:

<td class="trow1"><input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="3" onfocus="if(this.value == '') { this.value = 'Subject'; }" /></td>

... so it puts something in if it's empty, but then it'll only do it when they click in it and if they click in it they'd probably be typing in it anyway...

EDIT: OK, do this... in the private_send template, before </head>, add:

<script type="text/javascript">
function subjectFill()
{
	subject = document.getElementById("subject");
	if(subject.value == '')
	{	
		subject.value = 'Subject';
	}
}
</script>

Change <body> to <body onload="subjectFill();">

Then change

<td class="trow1"><input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="3" /></td>

to

<td class="trow1"><input type="text" class="textbox" name="subject" id="subject" size="40" maxlength="85" value="{$subject}" tabindex="3" onfocus="if(this.value == 'Subject') { this.value = ''; }" onblur="if(this.value == '') { this.value = 'Subject'; }" /></td>

Just adding an ID to it, and onfocus/onblur. That works for me. Now, when they load the page, it'll put Subject in to begin with if there isn't already a subject, remove it if they then click in it, and put it back if they remove the text and click something else.
Why not make this simple edit to private message template...
(private_send)
Find:
<td class="trow1"><input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="3" /></td>
Replace with:
<td class="trow1"><input type="text" class="textbox"
name="subject" size="40" value="No Subject" maxlength="45" value="{$subject}" tabindex="3"
/></td>

Thats what i've done, not seen any glitchs from it :\
You shouldn't use two value fields. I don't know which would actually be used, but the whole point of {$subject} being there is it can autofill it if necessary, if that gets overridden by the other value then it'll never work.
Hello!

you it is possible to have the same thing when creating a new topic in a forum?
(2010-12-21, 01:29 PM)bruno36 Wrote: [ -> ]Hello!

you it is possible to have the same thing when creating a new topic in a forum?

http://www.mybbcentral.com/thread-2408.html
the message is cleared automatically when you click in the test area?
Please bake this into 2.0. So annoying to send a quick message and have to put in a subject.
Pages: 1 2