Forums / Setup & design / Scope of $current_user variable
James Ward
Thursday 08 December 2005 11:49:25 am
I have 2 pieces of code on the same page which use the $current_user variable.
In top.tpl (at the top of the page) I check to see if a user is logged in with the following code:
{if eq($current_user.contentobject_id,$anonymous_user_id)}
This check always behaves correctly and if I output the two id's I can see they are correct.
Further down on the same page, included in another file I do a similar check in product.tpl. However this check always fails and if I output the ids they have no value.
I tried adding # in front of the variable names in case of a scope issue. There is no mention of when these variables will NOT be available on the doc page:http://ez.no/doc/ez_publish/technical_manual/3_6/templates/the_pagelayout/variables_in_pagelayout
Any thoughts on why these variables cease to exist?
working at www.wardnet.com blogging at www.jamesward.ca
Łukasz Serwatka
Monday 12 December 2005 12:02:34 am
Hi James,
This variables are available only in pagelayout.tpl. What you can do in product.tpl is fetch current user and compare it with variable AnonymousUserID from site.ini for example:
{def $current_user=fetch( user, current_user )} {if eq( $current_user.contentobject.id, ezini( 'UserSettings', 'AnonymousUserID', 'site.ini' ) )} . . .
Personal website -> http://serwatka.net Blog (about eZ Publish) -> http://serwatka.net/blog