PDA

View Full Version : Navbar Template Conditionals Help


Mickie D
02-17-2013, 10:39 AM
Hi all,

Looking for some conditionals that correspond to the navbar template.

Example If I am on showthread page, I would like to call the title of thread (first post) in the navbar.

Something like this


<vb:if condition="THIS_SCRIPT == 'showthread'">
{raw thread.info[post]}
</vb:if>


Not sure what variable is used for navbar?

Or if it needs a plugin?

Thanks
Mick

kh99
02-17-2013, 10:46 AM
I'd have to test it to be sure, but you could try {vb:raw GLOBALS.threadinfo.title}

Mickie D
02-17-2013, 12:35 PM
I think vbulletin.org was lagging earlier as I replied to this?

That worked perfect, I have tried to thank you in the last two posts where you have helped me but it says I cannot thank you because you was the last person I thanked... just shows how helpful you are :)

Thank you very much for the code.

Mick

kh99
02-17-2013, 07:46 PM
Thanks. Looking at it again, you might want vb:raw instead of vb:var - I was thinking you should handle any html tags, but the SHOWTHREAD template uses vb:raw so it must be handled elsewhere.

Mickie D
02-18-2013, 09:11 AM
Cheers, I changed it to raw :)

Can I ask what the difference is as both worked ?

Just for future reference.

Regards
Mick

kh99
02-18-2013, 12:25 PM
The only difference is that 'var' will run the value through htmlspecialchars() (http://php.net/manual/en/function.htmlspecialchars.php), which encodes html characters like '<' and '>' (as &lt; and &gt;) so that they will appear as '<' and '>' in the output. Otherwise they would act as html tags, so if someone were to put html tags in the thread title they could affect the look of your page.

I have to admit I don't know offhand how it's handled - maybe those characters aren't allowed at all in thread titles or something. But you could do a test by creating a thread with a title like '<b>Bold</b>' and then see if vb:raw looks different than vb:var.

Edit: I just went ahead and tried it. If you create a thread with title '<b>Bold</b>' and use vb:var you get &lt;b&gt;Bold&lt;/b&gt;, which means that htmlspecialchars is being applied twice. So you need to use vb:raw in this case, or you might end up with strange things like that.