[SOLVED] {if} tag for logged in status?

johnnaked

Joined: 2004-11-30
Posts: 5
Posted: Tue, 2004-11-30 23:32

I was curious as to if there was an {if} tag I could throw in the templates to display certain things only if you were logged in.

 
lvthunder

Joined: 2003-09-12
Posts: 808
Posted: Wed, 2004-12-01 06:31

I'm not a 100% sure but I think this is it.

{if isset($layout.systemContent.core.login)}
 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2004-12-01 07:02

good guess, but that is set when the login form on the sidebar will be shown (so it kinda could work, if it's set then you're not logged in)

we don't have anything specifically for that, but here's something that should be reliable, as long as you don't change the username for your guest user:

{if $layout.user.userName != 'guest'}

 
johnnaked

Joined: 2004-11-30
Posts: 5
Posted: Thu, 2004-12-02 04:05

It doesn't look like that will do it for me.

Right now I've got:

Quote:
{if isset($layout.systemContent.core.login)}
{if !empty($child.itemLinks)}
<select onchange="{literal}javascript:if (this.value) { newLocation = this.value; this.options[0].selected = true; location.href= newLocation; }{/literal}" class="giActionSelect">
<option label="{if $child.canContainChildren}{g->text text="&amp; album actions &amp;"}{else}{g->text text="&amp; item actions &amp;"}{/if}" value="">{if $child.canContainChildren}{g->text text="&amp; album actions &amp;"}{else}{g->text text="&amp; item actions &amp;"}{/if}</option>

{foreach from=$child.itemLinks item=link}
<option label="{$link.text}" value="{$link.url}">{$link.text}</option>
{/foreach}
</select>
{/if}
</div>
{/if}

I'm trying to make sure that the action select beneath photos and albums only shows up if you are logged in. As of now, it doesn't show up either way.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Thu, 2004-12-02 06:59

looks like you tried the first suggestion.. hmm..

 
johnnaked

Joined: 2004-11-30
Posts: 5
Posted: Thu, 2004-12-02 07:30

Ah! I replied prior to refreshing the page.

That's working perfectly, thanks mindless.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2005-04-19 18:35

I have made a standard template variable so user info is available to every view. You can reference these in any tpl: $user.userName, $user.fullName, $user.isGuest, $user.isRegisteredUser, $user.isAdmin
Update from cvs in a few hours or get tomorrow's nightly snapshot to try this out. If you have any references to $layout.user in your local tpl files you'll need to change these to just $user.