Re: How to hide a menu item or sub menu item

andy varganov <[email protected]> Fri, 15 Aug 2003 17:08:14 +0100
Newsgroups gmane.comp.cms.xaraya.knowledge-base
Organization Xaraya News Server
Message-ID <BB62C3FE.10C16%[email protected]>
On 15/8/03 15:26, in article bhiqib$ma1$1-111RdWWlOxkOkXtL6OYfHgC/[email protected], "Banzai"
<[email protected]> wrote:

> Is there anyway to hide a menu item or sub menu item ? ie. I would like to
> make a particular menu item visible only users who are logged in. For
> guests, the menu item should be hidden.
> 
> I know how to hide a block menu (by adding priv) .. but I want the menu
> block to be visible and only a particular menu item to be hidden for
> certain users. Is there anyway to do that?
> 
> Thanks
> Banzai 
> 

Sure there is a way to do it, especially easy for hiding from 'non-logged
in' individuals.. ;-) Just override the block template and put that menu
item(s) inside a simple user api check, something like this:

<xar:if condition="xarUserIsLoggedIn()">
    <xar:comment>good logged-In user deserves to see this item</xar:comment>
    <a href="my_precious_menuitem.php">Take This, Say Thankyou Banzai</a>
</xar:if>


Or with a clue

<xar:if condition="xarUserIsLoggedIn()">
    <xar:comment>good logged-In user deserves to see this item</xar:comment>
    <a href="my_precious_menuitem.php">Take This, Say Thankyou Banzai</a>
<xar:else />
    <xar:comment>bad lazy user deserves to see this</xar:comment>
    <a href="login.php">Login to see this item - It's HOT!</a>
</xar:if>

Hope it helps
Andy