View Full Version : How to hyperlink to start New Thread with Title?
bzcomputers
07-19-2012, 09:14 AM
I know you can hyperlink to start a new thread in a specific forum with this:
http://www.YOURSITE.COM/forum/newthread.php?action=newthread&forumid=XXX
Is there anyway to add a Thread Title to the link, so it automatically inserts in the the new thread?
You would need a plugin to do that, but it's a one liner. Use hook newthread_form_start and this code:
$newpost['title'] = $vbulletin->input->clean_gpc('r', 'subject', TYPE_STR);
and then add something like &subject=thread%20title to your url. (Of course your title will need to be URL-encoded, specifically spaces need to be represented as %20).
bzcomputers
07-19-2012, 12:04 PM
You would need a plugin to do that, but it's a one liner. Use hook newthread_form_start and this code:
$newpost['title'] = $vbulletin->input->clean_gpc('r', 'subject', TYPE_STR);
and then add something like &subject=thread%20title to your url. (Of course your title will need to be URL-encoded, specifically spaces need to be represented as %20).
Thanks for the quick response! Code works great and even being the novice I am, I was able to implement it quickly and easily with your simple instructions.
That being said, I have one follow up question...
If I attempt use a vBulletin variable in the Thread Title and it contains an ampersand in the variable the Thread Title will stop processing at that point and cut the rest of the title off. Is there a work around for this?
Example: I use ...&subject=Issues%20with%20{vb:raw cruiseline}
Where cruiseline = P&O Cruises, then the results displayed for title are "Issues with P".
Use {vb:urlencode cruiseline} instead of vb:raw.
BTW, user Sarteck came up with virtually the plugin I did, but deleted the post because I happened to post first. But I wanted to point something out that I hadn't thought of - I used 'subject' because that's what's used by the vb code when you submit a thread, but there's no reason you couldn't use any name you want, as long a it's the same in the plugin and where you construct the link. So for instance if you like &title=something better you could use that.
bzcomputers
07-19-2012, 03:39 PM
Use {vb:urlencode cruiseline} instead of vb:raw.
BTW, user Sarteck came up with virtually the plugin I did, but deleted the post because I happened to post first. But I wanted to point something out that I hadn't thought of - I used 'subject' because that's what's used by the vb code when you submit a thread, but there's no reason you couldn't use any name you want, as long a it's the same in the plugin and where you construct the link. So for instance if you like &title=something better you could use that.
$cruiseline = P&O Cruises
Using: &subject=Issues%20with%20{vb:raw cruiseline}
{vb:raw cruiseline} = "Issues with P"
{vb:urlencode cruiseline} = "Issues with cruiseline"
As you can see that didn't work.
(Thanks, for the additional info on the plugin.)
$cruiseline = P&O Cruises
Using: &subject=Issues%20with%20{vb:raw cruiseline}
{vb:raw cruiseline} = "Issues with P"
{vb:urlencode cruiseline} = "Issues with cruiseline"
As you can see that didn't work.
oops, try {vb:urlencode {vb:raw cruiseline}}
bzcomputers
07-19-2012, 03:58 PM
oops, try {vb:urlencode {vb:raw cruiseline}}
Thanks for the quick replies, that did it - works perfect now!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.