Log in

View Full Version : conditionals not working


harmor19
01-10-2006, 12:26 AM
In my product I check what number is in the field then I write an HTML conditional for the appropiate parts.

//not logged in
if($dlink['view_link] == 1)
{
$custom_droplinks .= "<if condition='".$show['registerbutton']."'>
<tr><td class='vbmenu_option'>$img<a href='".$dlink['url']."' target='$new' title='".$dlink['alt']."'>".$dlink['name']</a></td></tr></if>";
}
//is logged in
elseif($dlink['view_link] == 2)
{
$custom_droplinks .= "<if condition='".$show['member']."'>
<tr><td class='vbmenu_option'>$img<a href='".$dlink['url']."' target='$new' title='".$dlink['alt']."'>".$dlink['name']</a></td></tr></if>";
}
//both
else
{
$custom_droplinks .= "
<tr><td class='vbmenu_option'>$img<a href='".$dlink['url']."' target='$new' title='".$dlink['alt']."'>".$dlink['name']</a></td></tr>";
}

The hook I'm using is "global_start"

peterska2
01-10-2006, 12:29 AM
you've got a typo.

<if condition='".$show['meber']."'>
should be
<if condition='".$show['member']."'>

apart from that, I'm nto too hot on php but it looks ok to me.

harmor19
01-10-2006, 12:31 AM
I fixed that but still doesn't work.

Maybe if I cancel out the array
<if condition='.\$show['member']."'>

calorie
01-10-2006, 12:38 AM
Make sure $show['member'] is set and try...

<if condition="$show[member]">

harmor19
01-10-2006, 01:12 AM
I tried this but this doesn't work
<template name="custom_droplinks" templatetype="template" date="1128881080" username="harmor19" version="3.5.0"><![CDATA[<if condition="$show[member]">$custom_droplinks</if>
]]></template>

Maybe it's my hook location?

calorie
01-10-2006, 01:22 AM
Oops, missed your hook location. Yes it's that b/c $show['member'] is not defined until after that hook. In global you'll see...

if ($vbulletin->userinfo['userid'])
{
$show['guest'] = false;
$show['member'] = true;
}
else
{
$show['guest'] = true;
$show['member'] = false;
}

So, instead of <if condition="$show[member]"> try...

<if condition="$bbuserinfo[userid]">

harmor19
01-10-2006, 10:19 AM
i'll do that tonight.
thanks