MyBB Community Forums

Full Version: Set a default value for a thread's subject by attribute within the URL
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I'm trying to set up my New Thread page in such a way that the subject input's value is preset (though not predetermined, ie can be altered by the user) as the result of an attribute within the URL.

For example, on a certain page there is a link to http://community.mybb.com/newthread.php?...ubject=Set a default value for a thread's subject by attribute within the URL. The words "Set a default value for a thread's subject by attribute within the URL" would already be in the input box.

I seem to remember coming across quite a simple solution to a task like this quite some time ago, so either I'm misremembering or being daft about it.

The desired result is that, when a user of my website (a fansite for The Rolling Stones) goes to an album's page (E.g. this), a PHP script checks whether a MYBB thread exists with the album's title. If so, the hyperlink takes the user to the specific thread. If not, the link takes the user to newthread.php, but with this desired pre-set subject input of the album title. With the example page I've given, there is no such discussion thread for 'Goats Head Soup', so the link should take the user to newthread.php with 'Goats Head Soup' already in the subject-input. (NB I have the script sussed)

I hope that I have explained this well and someone can help me out Smile

Thanks a lot,
Patrick Todd
You need a plugin for this.
So... the request forum for plugins are here: Requests
Maybe a developer will make a plugin for your request.
Ooft, that's frightening! I'll see if I can get anywhere myself before putting a request in. Cheers for the fast response!
Could you point me to a simple plugin that deals specifically with altering the New Thread page? If you know one off hand, I don't want to put you to any trouble. Thanks
Run this code in newthreads_start hook:

global $mybb, $subject;
if(isset($mybb->input['subject']))
{
    $subject = htmlspecialchars_uni($mybb->input['subject']);
}

Use my Hooks plugin if you don't want to write a dedicated plugin file for this. Or you could edit it into newthread.php directly (using my Patches plugin if you like), after
// Otherwise, this is our initial visit to this page.
        else
        {
Thanks, this is exactly what I was looking for. I guess it's more complicated if I want to disable the ability to change the subject, so I shall stick with this. Cheers man!