Please help me get an If Then statement correct to block tabs for Guests

Jamie

Well-known member
I have the shoutbox installed and since guests can't use it I would like to just hide the tab for anyone that can't use it.

So what is the code I am looking for?

<if guest>
Show Guest menu
<else />
Show Member menu
</if>


Thanks!
Jamie
 
Figured it out.. In case anyone else is wondering, here is an example I was playing around with to see if it worked.

For Guest, the home tab is called Continue and for Members it's called Home.. I know, silly but it was a quick exercise to see how it worked. :)

<xen:if is="{$visitor.user_id}">
<li class="navTab home PopupClosed"><a href="{$homeLink}" class="navLink">{xen:phrase continue}</a></li>
<xen:else />
<li class="navTab home PopupClosed"><a href="{$homeLink}" class="navLink">{xen:phrase home}</a></li>
</xen:if>
 
For Guest, the home tab is called Continue and for Members it's called Home.

...

<xen:if is="{$visitor.user_id}">
<li class="navTab home PopupClosed"><a href="{$homeLink}" class="navLink">{xen:phrase continue}</a></li>
<xen:else />
<li class="navTab home PopupClosed"><a href="{$homeLink}" class="navLink">{xen:phrase home}</a></li>
</xen:if>

Based on that description I think you got the condition reversed. The first block is true for logged in users. The second block is true for guests.
 
Oh.. i thought this line: <xen:if is="{$visitor.user_id}"> was saying if this user IS a visitor... no?

Well, you are accessing the $visitor[] array, but you are specifically checking the user_id. Only logged in users have user_ids.

The direct condition to check for guests is:

Code:
<xen:if is="!{$visitor.user_id}">
	FOR GUESTS
</xen:if>

This reads, "if the user does not have a user_id."
 
Ah, ok. Thanks for your help! btw, how did you wrap that in the blue code tag? I looked but couldn't see a BBcode tag for that and ended up with smiles in my example. :)

Jamie
 
That condition will determine if the person currently visiting the page has a user id, which only logged in users would.. so yes it is reversed.

EDIT: Ahh too late.
 
Top Bottom