Checking if current page is displayed in menu

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
pschoenb
Forum Members
Forum Members
Posts: 92
Joined: Sun Jul 15, 2007 1:18 pm

Checking if current page is displayed in menu

Post 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?
Regards,
Patrick
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Re: Checking if current page is displayed in menu

Post 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
pschoenb
Forum Members
Forum Members
Posts: 92
Joined: Sun Jul 15, 2007 1:18 pm

Re: Checking if current page is displayed in menu

Post 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.
Regards,
Patrick
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Re: Checking if current page is displayed in menu

Post 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
pschoenb
Forum Members
Forum Members
Posts: 92
Joined: Sun Jul 15, 2007 1:18 pm

Re: Checking if current page is displayed in menu

Post by pschoenb »

No, there is a page option to hide a specific page in the menu. This is what I mean.
Regards,
Patrick
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Re: Checking if current page is displayed in menu

Post 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
Post Reply

Return to “CMSMS Core”