Page 1 of 1

Hide "Home" link on navigation when user is on the home page

Posted: Mon Mar 10, 2008 7:02 pm
by joecannes
This may be a simple answer, but I cant find it and I am a newbie!

How do I not show the "Home" link in the navigation on the home page, but it appears when I am navigating other pages?


JC

Re: Hide "Home" link on navigation when user is on the home page

Posted: Mon Sep 29, 2008 4:26 pm
by belgirl
I would like to do the same thing, please! 

Re: Hide "Home" link on navigation when user is on the home page

Posted: Mon Sep 29, 2008 4:48 pm
by RonnyK
Do you mean in the regular menu, or in a link?

SHould other pages that are being shown at the time, not be shown in the menu while showing?

Ronny

Re: Hide "Home" link on navigation when user is on the home page

Posted: Mon Sep 29, 2008 5:01 pm
by NaN
You could modify your menu template.
You just need to check for the contents alias or the contents id.

In the backend in "Layout->MenuManager" select the template you use for your page.
(If it is not imported to the database do so and modify your template by using this template instead. Or just browse with an FTP programm to the folder modules/MenuManager/templates and modify the file directly.)

Within your template should be something like this (in this case the example code is taken from the original simple_navigation.tpl):

Code: Select all


{if $node->current == true}
<li class="currentpage"><h3><dfn>Current page is {$node->hierarchy}: </dfn>{$node->menutext}</h3>

This is where the template styles the current pages link. (in this case it is a headline ...)
There you just need to insert below the {if $node->current == true} an additional if-loop to check the contents alias (or the contents id - whatever makes you happy):

{if $node->current == true}
{if ($node->alias=='home'}
{if $node->current == true}
Current page is {$node->hierarchy}: {$node->menutext}
{/if}
So whenever the current content is "home" it wont be displayed in the menu.
You also could give the an id with the pages alias and hide the menu link via stylesheets:

{if $node->current == true}
alias" [/b]>Current page is {$node->hierarchy}: {$node->menutext}
Now you just need to add to your stylesheets:

Code: Select all


ul li#home {
   display:none;
   margin: 0;
   padding: 0;
   border: none;
}


Re: Hide "Home" link on navigation when user is on the home page

Posted: Mon Sep 29, 2008 9:12 pm
by belgirl
Thanks--for me, it would be hiding a home link--not in the menu. (like a "back" button) Is this possible?

Re: Hide "Home" link on navigation when user is on the home page

Posted: Tue Sep 30, 2008 4:26 am
by RonnyK
If you only want a specific link want to be shown on all pages but the HOME-page, you could insert something like the {cms_selflink} to the homepage, wrapped inside an if statement.

So with the cms_selflilnk:
{if $pagealias neq 'home'}
{cms_selflink page="home" text="Home"}
{/if}
or with a a-href:
{if $pagealias neq 'home'}
Home
{/if}
Ronny

Re: Hide "Home" link on navigation when user is on the home page

Posted: Tue Sep 30, 2008 3:51 pm
by belgirl
The home link I have is currently in the template.  Can that cms_selflink be used in template or does it have to actually be used in the home page only?

Thanks!

Re: Hide "Home" link on navigation when user is on the home page

Posted: Tue Sep 30, 2008 6:11 pm
by NaN
It can be placed anywhere you want it to.
Because the link is only shown if you are notat a specific page.
In this case the link is only shown if the page alias (wich you can set at the options tab when editing a page; by default it will be filled automatically by a "websafe" version of the menu text) is not "home".
I would prefere to place it in the Template. (Since it is seen at every page except the page you specified.)
In order to get always the right link to that page i would use the first version of Ronnys examples.

Re: Hide "Home" link on navigation when user is on the home page

Posted: Tue Sep 30, 2008 8:13 pm
by belgirl
Hmmm..neither of these examples are working for me.  This is what I have in the template:

{if $pagealias neq 'micro-auto-paint'}
{cms_selflink page="micro-auto-paint" text="Return to Micro Auto Paint"}
{/if}

I do have friendly urls although I don't know if that would make a difference.  The link is still showing up on the "micro-auto-paint" page.  I have doubled checked the page name, and it is correct.  What am I doing wrong?  :(

Re: Hide "Home" link on navigation when user is on the home page

Posted: Thu Oct 02, 2008 5:43 pm
by NaN
Maybe the variable $pagealias is wrong.
Try $page_alias, $content_alias, $content_name or $page_name... just type {get_template_vars} in your template to see what variables contains what values.

Or the alias of the page is not "micro-auto-paint"? Take a look into the options tab again when editing that page to get the right alias.

I'm not sure but since you are using "-" within your alias it could be that you need to use the double quotes (") instead of single qoutes (').

Re: Hide "Home" link on navigation when user is on the home page

Posted: Thu Oct 02, 2008 8:01 pm
by belgirl
Hi-- my page alias is correct--double quotes didn't work.  :(  Any other ideas?

Re: Hide "Home" link on navigation when user is on the home page

Posted: Fri Oct 03, 2008 7:15 pm
by viebig
on your template

Code: Select all

{if $page_alias == 'home'}
{menu excludeprefix='home'}
{else}
{menu}
{/if}

Re: Hide "Home" link on navigation when user is on the home page

Posted: Fri Oct 03, 2008 7:17 pm
by viebig
belgirl wrote: Hi-- my page alias is correct--double quotes didn't work.   :(  Any other ideas?
use $page_alias with the underline

Re: Hide "Home" link on navigation when user is on the home page

Posted: Fri Oct 03, 2008 8:06 pm
by belgirl
viebig wrote:
belgirl wrote: Hi-- my page alias is correct--double quotes didn't work.   :(  Any other ideas?
use $page_alias with the underline
THAT WAS IT!!  I was simply missing the underscore..Ah...brilliant!  Thanks everyone.  Working great!