YOOtheme Pro is here! The best WordPress and Joomla theme. Learn more

Avatar danny.malouin asked

Wrap a position with an if registered condition

Hi,

I'm trying to figure out how I would render a Zoo element in a position ONLY of the user is NOT logged in (hide it when logged in / registered).

<?php if ($this->checkPosition('links')) : ?>
<ul>
<?php echo $this->renderPosition('links', array('style' => 'uikit_subnav')); ?>
</ul>
<?php endif; ?>

would have to be something like

<?php if NOT REGISTERED ?>
<ul>
<?php echo $this->renderPosition('links', array('style' => 'uikit_subnav')); ?>
</ul>
<?php endif; ?>

Any thougts ?
Thanks
Danny

  • ZOO

4 Answers

1

Avatar michael.maass Support Online answered

would have to be something like
<?php if NOT REGISTERED ?>
<ul>
<?php echo $this->renderPosition('links', array('style' => 'uikit_subnav')); ?>
</ul>
<?php endif; ?>
Any thougts ?

As "not registered" should be similar to being a "guest", please try

<?php  if(JFactory::getUser()->guest) : ?>  
<ul>  
<?php echo $this->renderPosition('links', array('style' => 'uikit_subnav')); ?>  
</ul>  
<?php endif; ?>

More information can be found in the Official Joomla Documentation.

Thank you

Edited

0

Avatar danny.malouin answered

Yes but will this fetch the data if the user is "registered" too ? I don't want the registered users to see this data (it's for non registered only).
Thanks for your help btw :-)
Danny

0

Avatar michael.maass Support Online answered

Yes but will this fetch the data if the user is "registered" too ?

Did you try? It will help you to find out about the result.

The condition checks if the user level is "guest". If this is applies the returned result is "true", and the ul wil be displayed.

A "Public" user — anyone who is not logged in at the frontend — belongs to this user level.

Any higher level — Registered, Editor, Administrator, Super Administrator — is not a "guest", consequently the returned result is "false", the condition does not apply, and the ul is not displayed.

Thank you

Know someone who can answer? Share a link to this question via email or twitter.