Log in

View Full Version : Help me start a new thread from within a script...


JJR512
10-02-2005, 02:29 AM
If a certain circumstance is true, I want a redirect to go newthread.php and have the Title and Message parts filled out with pre-determined info. How do I do this?

This will be done from one of the admincp pages (not going to say which at this time).

So far, I have:

if ($_POST['discussannouncement'] == '1')
{
define('CP_REDIRECT', $vboptions[bburl].'/newthread.php');
}
else
{
define('CP_REDIRECT', '-------.php');
}
As it is, this works fine. If the condition is true, it goes to newthread.php, and if it's not, it goes to itself, as is the normal behavior for the particular script. The only problem with the code above is that I get an invalid forum message, but I've already figured out I can solve that by changing "newthread.php" in the code above to "newthread.php?f=2" (or some other number).

But I'd like for the new thread page to have the Title and Message pre-filled out with the values of two separate variables.

Is there a way to do this?

Thanks in advance! :)

Marco van Herwaarden
10-02-2005, 06:44 AM
Just set the correct variables, shouldn't be much of a problem, check how preview works. ;)

PS Not difficult to gues what you are working on. :D`

Kirk Y
10-02-2005, 02:36 PM
Especially with 'discussannouncement' in the conditional there... lol. Sounds like a good idea, though.

JJR512
10-02-2005, 03:39 PM
Hehe...

But I guess my problem is what are the correct variables. The way I'm trying to do it now, the only way to pass the variables is through the URL, correct?

On the newthread.php page, the name of the subject field is "subject". I've tried loading newthread.php?f=2&subject=test, yet the subject stays blank. But if I edit newthread.php and find the last time $subject is set to something, then after that add $subject="test", and load the page newthread.php?f=2, test IS in the subject.

To isolate the problem, in the newthread template I renamed the subject field to subject666, then loaded the page newthread.php?f=2&subject666=test. Still, the subject line was blank.

What am I doing wrong?

...check how preview works...
Sorry, I missed that bit when I posted the reply. I'll check into that, but since you mention it, makes me wonder if it might be easier to make my hack load the newthread page in its preview stage, rather than in its newthread stage? I guess I'm thinking that because the preview stage is designed to be already filled out, whereas the newthread stage is designed to be blank. Does that make sense?

Rostor
11-24-2005, 01:53 PM
Hi JJR512,

I don't know if you need the code anymore, in any case I give you my solution (that is real similar to your) :D

In newthread.php I added 2 lines,

First for the text that must apper in messagetextarea
// ############################### start new thread ###############################
if ($_REQUEST['do'] == 'newthread')
{
$newpost['message'] = $_REQUEST['messaggionews'];


Second for the subject just where you said,
$subject = $newpost['title'];
$subject = $_REQUEST['oggettonews']; #ROSTOR


Then I put the value in newthread template for the sbject :

<input type="text" class="bginput" name="subject" value="$subject" value="$oggettonews" size="40" maxlength="85" tabindex="1" />

That's all :)

Now you can open a 3D with a link like this : newthread.php?do=newthread&f=1&oggettonews=YOUROBJECTHERE&messaggionews=YOURMESSAGEHERE

bYE :)