[solved] Separate submenus with parent link as menu header

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
pomfret
Forum Members
Forum Members
Posts: 14
Joined: Wed Dec 31, 2008 7:19 pm
Location: Connecticut, USA

[solved] Separate submenus with parent link as menu header

Post by pomfret »

I've been digging around over the weekend and just can seem to accomplish this task.  Any help will be greatly appreciated.

I have a horizontal menu that contains four primary parent items and children items of up to two levels deep.  This horizontal menu only shows the first level of child links.  When one of the child links are clicked, the resulting page has a new vertical menu in the left sidebar that contains the 3rd level of links for said parent menu item.  ie.:

1. Explore
- 1.1 Where to stay
=============(above are primary horizontal menu items, below are secondary vertical menu items)
- - 1.1.1 Inns & Spas
- - 1.1.2 Hotels & Motels
- - 1.1.3 Bead & Breakfast
- - 1.1.n etc.

I have both the horizontal and vertical menus appearing as expected.  What I would like to do is add a header to the vertical menu that has the value of it's direct parent menutext.  Using the example above, the vertical sidebar menu would look like the following when "Where to stay" is clicked in the primary menu:

*Where to stay*
- 1.1.1 Inns & Spas
- 1.1.2 Hotels & Motels
- 1.1.3 Bead & Breakfast
- 1.1.n etc.

For the life of me, I do not seem to be able to obtain the child menu's parent menutext value and use it as a header for the vertical menu ("Where to stay" in this case).  Something along the lines of $node->parent_menutext is exactly what I'm looking for...  I think.

Thanks,

Brian
Last edited by pomfret on Mon Apr 13, 2009 6:36 pm, edited 1 time in total.
tyman00
Power Poster
Power Poster
Posts: 906
Joined: Tue Oct 24, 2006 5:59 pm

Re: Separate submenus with parent link as menu header

Post by tyman00 »

You may want to install the cgSimpleSmarty module and check out the help section there. I believe that it includes something for that exact purpose.
If all else fails, use a bigger hammer.
M@rtijn wrote: This is a community. This means that we work together and have the same goal (a beautiful CMS), not that we try to put people down and make their (voluntary) job as difficult as can be.
pomfret
Forum Members
Forum Members
Posts: 14
Joined: Wed Dec 31, 2008 7:19 pm
Location: Connecticut, USA

Re: Separate submenus with parent link as menu header

Post by pomfret »

Absolutely wonderful!!

I thought I remembered seeing such functionality, but couldn't recall the module that provided it (the phrase "SimpleSmarty" even popped into my mind, forgot about the cg prefix).

{$cgsimple->get_page_title($cgsimple->get_parent_alias(),'')} worked a treat.

Thanks a bunch tyman and calguy!

Brian
pomfret
Forum Members
Forum Members
Posts: 14
Joined: Wed Dec 31, 2008 7:19 pm
Location: Connecticut, USA

Re: [solved] Separate submenus with parent link as menu header

Post by pomfret »

FYI, I was missing an important piece of logic...  If you clicked on the "Where to stay" menu item in my example, the title of my sidebar menu turned out to be that of the 1st level menu item.  Clicking on any of the children in the sidebar menu produced the expected menu title.

As a work-around, I came up with the following code.  Seems to work for my needs.

Code: Select all

{if $cgsimple->has_children() == true}
  {$cgsimple->get_page_menutext()}
{else}
  {$cgsimple->get_page_menutext($cgsimple->get_parent_alias(),'')}
{/if}
Now if you click on any 2nd level menu entry which generates a 3rd level menu, it will pull the menutext from the same page.  Otherwise the menu title is that of the parent menu item.

Oh, and the code in my previous post is a copy/paste from the cgSimpleSmarty module help page which has the incorrect code example for get_page_menutext([$alias],[$assign])...  oops!

Brian
Duketown

Re: [solved] Separate submenus with parent link as menu header

Post by Duketown »

All,

Thanks since this helped me a big deal.

Tip: I wanted to install cgsimplesmarty using Module Manager. However I got the message (at this moment using CMSMS 1.5.4) that the module was incompatible. I went over to the files of CGSimpleSmarty and used the previous version (I used version: 1.4.1). No problems with regards to incompatibility.

Duketown
Post Reply

Return to “CMSMS Core”