[Guide] Template Conditionals

Status
Not open for further replies.

Mikey

:mikey:
Staff member
Joined
Jan 26, 2008
Messages
17,836
How would I display something only if the user is online?

something like

Code:
<xen:if is="{$visitor.online} == 1">Code for online users</xen:if>
?

Not if the person who is viewing it is online, but if the user is online?
 

Vincent_imported

Trusted Member
Joined
Dec 1, 2010
Messages
747
How would I display something only if the user is online?

something like

Code:
<xen:if is="{$visitor.online} == 1">Code for online users</xen:if>
?

Not if the person who is viewing it is online, but if the user is online?

If you mean "online" as in "logged in", then you can use
Code:
<xen:if is="{$visitor.user_id}">Code</xen:if>
 

Mikey

:mikey:
Staff member
Joined
Jan 26, 2008
Messages
17,836
If you mean "online" as in "logged in", then you can use
Code:
<xen:if is="{$visitor.user_id}">Code</xen:if>
Thanks, but I kinda mean differently.

Sort of how the banners for online and offline work in that mod over at xenforo.com, where they show if a user is online or offline with ribbons?
 

Vincent_imported

Trusted Member
Joined
Dec 1, 2010
Messages
747
Thanks, but I kinda mean differently.

Sort of how the banners for online and offline work in that mod over at xenforo.com, where they show if a user is online or offline with ribbons?

Ah, well, I can tell you if you have a test installation of the plugin for me :D
 

gldtn_imported

OMG Member
Joined
Feb 6, 2011
Messages
20
What is wrong with this?
Code:
<xen:if is="{xen:helper ismemberof, $user, x} AND {$user.is_admin} OR {$user.is_moderator}">
 

Floris

I'm just me :) Hi.
Staff member
Joined
Jan 1, 2001
Messages
60,100
for reference...

page_container template:

Code:
<p class="importantMessage">
controllerName: {$controllerName}, controllerAction: {$controllerAction} and viewName: {$viewName}.
</p>
 

Floris

I'm just me :) Hi.
Staff member
Joined
Jan 1, 2001
Messages
60,100
<xen:if is="in_array({$user.user_id}, array('X','Y','Z'))">
 

The Pet Board

OMG Member
Joined
Aug 23, 2011
Messages
86
The possibilities with this guide could be great... is there a way for me to use conditionals to show different usergroups different backgrounds?
 

Floris

I'm just me :) Hi.
Staff member
Joined
Jan 1, 2001
Messages
60,100
The style.php or css.php is loaded in the header somwhere,
you can wrap this around a conditional and load a different style id, I believe.
 

The Pet Board

OMG Member
Joined
Aug 23, 2011
Messages
86
The style.php or css.php is loaded in the header somwhere,
you can wrap this around a conditional and load a different style id, I believe.

This would be a great how to guide to add some new content to your site ;)
 

Floris

I'm just me :) Hi.
Staff member
Joined
Jan 1, 2001
Messages
60,100
<xen:if is="{$user.customFields.country}">
If the field has data this text will be shown
</xen:if>

<xen:if is="{$user.customFields.country} == 'United Kingdom'">
If the field contains 'United Kingdom' this text will be shown
</xen:if>
 
Status
Not open for further replies.
Top