PDA

View Full Version : Conditional question


pank
Sat 13th Oct '07, 11:51pm
When 1.0 came out I found an easy way to add a Blog button to the header template using:
<if condition="$loadblogtemplate">

When 1.0.1 came out it seemed to break that conditional. I found a new way to call that using:
<if defined="$VBBLOG_CACHED_TEMPLATES">

I just discovered an error with that conditional... It shows up even if a user does not have the blog installed. Also it still shows up if you turn your Blog off.

I dug a bit deeper and tried this (See code below). It seems to work well. The button will show if the Blog is enabled and it won't show if the Blog is turned off. Even better it won't show on a board without a Blog installed.

My question: Is this the best way to do this? It seems to work really well but before I update my skins I'd like to know if anybody has a better way or if this is the best route to take.
<if condition="$vbulletin->products['vbblog']">

I also did already try all the staff suggestions here (http://www.vbulletin.com/forum/showthread.php?t=241649).

Thanks.

Floris
Sun 14th Oct '07, 12:49am
Perhaps check if the option for one of the vb blog options is empty or not? if empty .. perhaps it's not installed?

<if condition="!empty($vbulletin->options['vbblog_trackback'])">The value is not empty, so it's set to yes or no, we can assume vbblog is installed?</if>

pank
Sun 14th Oct '07, 8:23pm
Thanks Floris :)

I just tried your code and it seems to work perfectly as well:
<if condition="!empty($vbulletin->options['vbblog_trackback'])">

The Blog button shows up in the header template when active, disappears when the Blog in deactivated, and does not show up on a forum with no Blog installed.

Now my question...
Is that a better conditional to use than the one I used?
Basically which one is a safer route to take for future Blog updates?

<if condition="!empty($vbulletin->options['vbblog_trackback'])">

or...

<if condition="$vbulletin->products['vbblog']">

Or, does it really make a difference?

Thanks again for the tip!

Freddie Bingham
Wed 17th Oct '07, 2:08pm
$vbulletin->products['vbblog'] should do fine.

pank
Wed 17th Oct '07, 9:23pm
$vbulletin->products['vbblog'] should do fine.

Works perfect in all situations!
Thank you Freddie and thank you to Floris :)