News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Pre-populate the post form

Started by Senkusha, March 20, 2006, 04:07:43 PM

Previous topic - Next topic

Senkusha

Is there a way to populate the post form with a subject and post data?  What I would like to do is write a peice of text with the subject included, and have the poster simply review the data to post to the forum.  Any suggestions?

Thanks!
--Senkusha
The Anime Brigade
Anime-style Role Playing Games and Discussion.
(SMF v. 2.1.4, PHP v. 8.0)

Senkusha

I figured out how to pre populate the subject (by adding it to the URL data), but I'm still troubled by how to populate the actual message data...if I'm not mistaken, the URL data can only hold about 512 bytes, correct?  I'll need much more data space.

By reviewing the post.php file, it appears to be checking $_REQUEST['message'] and $_REQUEST['subject'], however, when I set these values, nothing appears in the form.

Please help!

Thank you!
--Senkusha
The Anime Brigade
Anime-style Role Playing Games and Discussion.
(SMF v. 2.1.4, PHP v. 8.0)

Senkusha

Can anybody shed some light on this?  Please?  *begs*

Thanks!
--Senkusha
The Anime Brigade
Anime-style Role Playing Games and Discussion.
(SMF v. 2.1.4, PHP v. 8.0)

Elmacik

You would like to save the additional tail to the subject with it to database? Or just displaying it?
If the first one, open Post.php which is in Sources folder.
Code (Find) Select

// Collect all parameters for the creation or modification of a post.

Code (Add after) Select

if (isset($_POST['subject'])) $_POST['subject'] = 'Foo bar', $_POST['subject'];
Home of Elmacik

Senkusha

What I need is the following:

I have a special form that a member fills details out in.  Upon hitting a submit button, I would like one of those fields in the special form to be displayed in the Subject box on the post message form, and the rest of the data from the form would make up the body / message post itself.

Thanks!
--Senkusha
The Anime Brigade
Anime-style Role Playing Games and Discussion.
(SMF v. 2.1.4, PHP v. 8.0)

Elmacik

#5
Hmm.. Lets say you have a special post with a pre-subject item like this:

<form name="pres" action="index.php?action=post" method="post">
<input type="text" name="pre-subject" value="" />
<input type="submit" />
</form>


And lets say you did the following changes in Post.template.php ;
Code (Find) Select

<input type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" />

Code (Replace) Select

';
if (isset($_REQUEST['pre-subject'])) echo ' <input type="text" name="subject" value="', $_POST['pre-subject'],'" tabindex="', $context['tabindex']++, '" size="80" maxlength="80" />';
else echo ' <input type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" /> ';
echo '


If you now submit the special pre-form with a non-empty value, it will go to the message posting window with the same value in the subject box.
Is this what you ask for?
Home of Elmacik

Senkusha

YES!  :D  But doesn't post.php clear those fields when it runs?
--Senkusha
The Anime Brigade
Anime-style Role Playing Games and Discussion.
(SMF v. 2.1.4, PHP v. 8.0)

Elmacik

Hey if you need it to be there, then why you want it to clear :)
I set it so that it takes the subject from your pre-form.
But if you dont use the mentioned "pre-form", subject field will always be empty.
Home of Elmacik

Advertisement: