Removing the NavLinks submenu for guests

Kim

Well-known member
Hi all,

I am hoping someone who is a coding guru can give me an <if statement to remove the NavLinks submenu to guests, and tell me where to put it.

So that the forum NavTab does not have the submenu with "search forums" and "what's new" showing to non-logged in guests.

Also...

Can the What's New? be moved and if so how so, thanks so!

:D
 
The template is "navigation".

The way I found that is by searching for "whats_new" which is most likely to be the phrase name for the What's New link. Searching template content for that brings up only the navigation template.

Then you'll see this block of code here:

Code:
					<ul class="secondaryContent blockLinksList">
					<xen:hook name="navigation_tabs_forums">
						<xen:if is="{$visitor.user_id}"><li><a href="{xen:link 'forums/-/mark-read', $forum, 'date={$serverTime}'}" class="OverlayTrigger">{xen:phrase mark_forums_read}</a></li></xen:if>
						<xen:if is="{$canSearch}"><li><a href="{xen:link search, '', 'type=post'}">{xen:phrase search_forums}</a></li></xen:if>
						<xen:if is="{$visitor.user_id}"><li><a href="{xen:link 'watched/threads'}">{xen:phrase watched_threads}</a></li></xen:if>
						<li><a href="{xen:link 'find-new/threads'}">{xen:phrase whats_new}</a></li>
					</xen:hook>
					</ul>

Notice how most of them are already wrapped with a conditional? It's the same conditional you need. Ah, and also the "Search" link conditional is based on permissions. You can, if you wish, just prevent Unregistered usergroup from being able to search using usergroup permissions.

If you can't be bothered with that, or you do want them to search then you would just change the "{$canSearch}" condition to the visitor condition. It would all look like this:

Code:
					<ul class="secondaryContent blockLinksList">
					<xen:hook name="navigation_tabs_forums">
						<xen:if is="{$visitor.user_id}"><li><a href="{xen:link 'forums/-/mark-read', $forum, 'date={$serverTime}'}" class="OverlayTrigger">{xen:phrase mark_forums_read}</a></li></xen:if>
						<xen:if is="{$visitor.user_id}"><li><a href="{xen:link search, '', 'type=post'}">{xen:phrase search_forums}</a></li></xen:if>
						<xen:if is="{$visitor.user_id}"><li><a href="{xen:link 'watched/threads'}">{xen:phrase watched_threads}</a></li></xen:if>
						<xen:if is="{$visitor.user_id}"><li><a href="{xen:link 'find-new/threads'}">{xen:phrase whats_new}</a></li></xen:if>
					</xen:hook>
					</ul>

If you wanted to take it a step further.

Code:
					<ul class="secondaryContent blockLinksList">
					<xen:hook name="navigation_tabs_forums">
						<xen:if is="{$visitor.user_id}"><li><a href="{xen:link 'forums/-/mark-read', $forum, 'date={$serverTime}'}" class="OverlayTrigger">{xen:phrase mark_forums_read}</a></li></xen:if>
						<xen:if is="{$visitor.user_id}"><li><a href="{xen:link search, '', 'type=post'}">{xen:phrase search_forums}</a></li></xen:if>
						<xen:if is="{$visitor.user_id}"><li><a href="{xen:link 'watched/threads'}">{xen:phrase watched_threads}</a></li></xen:if>
						<xen:if is="{$visitor.user_id}"><li><a href="{xen:link 'find-new/threads'}">{xen:phrase whats_new}</a></li></xen:if>
						<xen:if is="!{$visitor.user_id}"><li><a href="login/">{xen:phrase sign_up_now}</a></li></xen:if>
					</xen:hook>
					</ul>

That adds a "Sign Up Now!" link which is only visible to guests (note the !) :)
 
Works a treat Chris! Only problem I have is I have set the NavLinks div to be width: auto; and I now have a little residule of it left .. argh!

Any ideas on how to get rid of it?

residule.webp

Also... the What's New?

Can I just pick up that and place it where I want, in say another template, without the <li

HTML:
<li><a href="{xen:link 'find-new/threads'}">{xen:phrase whats_new}</a></li>
 
Yes, forgot to say. Stick that code anywhere you like. Depending on where you put it, there may be a need to <li> or some other container for it depending on the styling required.

That's a little bit trickier.

You might need to create a new template called "hide_tab_links.css"

This should be the contents:

Code:
.navTabs .navTab.selected .tabLinks
{
	display: none;
}

And then in your navigation template (anywhere) put:

Code:
<xen:if is="!{$visitor.user_id}">
	<xen:require css="hide_tab_links.css" />
</xen:if>
 
That is wonderful thanks Chris :D Will test it out in a bit!

Thanks again for your help, most appreciated!!!!
flowers.gif
 
Ahh... even easier. I forgot about this.

There's a class assigned to the HTML tag that reflects the logged in status.

Forget everything I said. Just add this to EXTRA.css:

Code:
.LoggedOut .navTabs .navTab.selected .tabLinks
{ 
	display: none;
}
 
God don't you just Lurve Xenforo! :D

Thank you so much for that Chris, I usually hassle poor Forsaken to death with my "how do I... " requests, lol but I figured I better not wear the poor boy out :p

Thank you again! You're a superstar!
 
Top Bottom