Page 1 of 1
Checking if current page is displayed in menu
Posted: Sun Apr 10, 2011 2:15 pm
by pschoenb
Hello,
I would like to display a snippet of content (a global content block in my case) only if the current page is also in the menu. Right now, I worked around the problem by duplicating the template, but this isn't a nice solution.
Is there a way to check this with Smarty. If so, how?
Re: Checking if current page is displayed in menu
Posted: Sat Apr 16, 2011 10:32 pm
by spcherub
Can you clarify what you mean when you say "if the current page is also in the menu"?
There are easy ways to get the alias of the current page and the aliases of the parent and root-level pages to use for conditional logic within your templates. If you can clarify your question, perhaps someone in this forum will be able to given you specific guidance.
-S
Re: Checking if current page is displayed in menu
Posted: Sat Apr 16, 2011 10:39 pm
by pschoenb
I am looking for a check that queries if the current visible page is a page that is displayed in the menu. Pages can also be excluded from the menu.
Re: Checking if current page is displayed in menu
Posted: Sat Apr 16, 2011 10:46 pm
by spcherub
@pschoenb - it may be just me but I'm still not clear about what you mean.
I understand the first part - "current visible page", but not sure about the second part "page displayed in menu". Are you referring to pages (like sub-pages) that may not be listed in the main navigation?
So you have a page structure something like this:
- Top Page 1
- Top Page 2
-- Sub Page 2.1
-- Sub Page 2.2
- Top Page 3
Only the Top pages are displayed in the page menu, but users can get to the Sub-pages if they click on some link in the top pages. Once they are there (on the sub-page) you want to be able to display (or hide) specific content that is otherwise hidden (or displayed) on the top-pages.
Is this your specific situation & need?
-S
Re: Checking if current page is displayed in menu
Posted: Sat Apr 16, 2011 10:51 pm
by pschoenb
No, there is a page option to hide a specific page in the menu. This is what I mean.
Re: Checking if current page is displayed in menu
Posted: Sat Apr 16, 2011 10:59 pm
by spcherub
Ok - got it.
Here's a simple way to do this:
Code: Select all
{if $content_obj->mShowInMenu != 1}
Hidden in Menu
{else}
Shown in Menu
{/if}
You can adapt this to show/hide content or other content blocks.
Hoep this help.
-S