This must be really easy: How does a template know where it is?

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Locked
AndyHolyer

This must be really easy: How does a template know where it is?

Post by AndyHolyer »

I want to have the standard CSS menu across the top of every page, and additionally a left sidebar which will contain the subpages *of*the*current*page*. I've worked out that the current page is in a smarty varaible "page" (Am I being really thick that I include this as {page} ?

Also the menu will be {menu template='minimal_menu.tpl'}, but I want start_page="{page}" as well. I've tried
{menu template='minimal_menu.tpl start_page="{page}"} but that just gives me back "}".

I've obviously got my syntax slightly screwed. Can someone guide the afflicted?

Thanks in advance,

A.
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: This must be really easy: How does a template know where it is?

Post by tsw »

why not use start_level=2 as instructed in menu module help?
AndyHolyer

Re: This must be really easy: How does a template know where it is?

Post by AndyHolyer »

I'd presumed that start_level=2 just showed the level-two entries, rather than the children of *this* page, so if you dig deeper in the structure (it will have more than one level) the entries listed will stay the same.

Is that not the behaviour? My mis-interpretation, if not.
User avatar
chead
Forum Members
Forum Members
Posts: 63
Joined: Tue Feb 06, 2007 4:01 am

Re: This must be really easy: How does a template know where it is?

Post by chead »

You won't have to do any complex Smarty work to figure out the current page. To do what you're describing -- a horizontal menu across the top of the page, with a vertical submenu in the left column -- try something like this:

Menu tags
Horizontal, level-1 only menu:
{menu template='minimal_menu.tpl' start_level='1' number_of_levels='1'}
This will give you a single set of just your top-level menu items as an unordered list. The menu template and its CSS determine the specific formatting of the menu, including whether or not it's displayed vertically or horizontally. Restricting the number of levels ensures you only show top-level items.

Vertical, only sub-menus of current "level 1" parent:
{menu template='minimal_menu.tpl' collapse='1' start_level='2'}
This will give you a second menu that shows second-level menu items based on the top-level of the current page. It's context-sensitive and will change as you select different top-level menu items. Collapse is an optional parameter that will hide level 3+ menu items unless you're viewing their parent page. Depending on your menu structure, you might not want or need that.

Parameters
  • start_level - controls the starting level for your menu
  • number_of_levels - how many levels (including the starting level) to also show
  • collapse - whether to show all lower-level pages (to the number_of_levels depth), or hide them unless they are submenus for the current page
More detailed information is in the help file for the menu module.
AndyHolyer

Re: This must be really easy: How does a template know where it is?

Post by AndyHolyer »

chead wrote:
Vertical, only sub-menus of current "level 1" parent:
{menu template='minimal_menu.tpl' collapse='1' start_level='2'}
This will give you a second menu that shows second-level menu items based on the top-level of the current page. It's context-sensitive and will change as you select different top-level menu items. Collapse is an optional parameter that will hide level 3+ menu items unless you're viewing their parent page. Depending on your menu structure, you might not want or need that.
I think that's what we're at cross purposes. I don't want the children of the current level 1 parent; I (or rather my customer) wants the children of the current page displayed. So, one day I might have some content (as if...): I want to display

You are here > Lewes > Support > Network Services > Andy Holyer

And have the children of my page displayed in the left-hand menu. The identity of my page is stored as smarty variable page (or I may use page-alias). and I need to set it as the start page of the left sidebar menu.
The syntax for this will come up again soon: the right sidebar will hold a news element; I've produced a news category for each top-level element, and it needs to pick that up to filter news items.

The other news summary element the customer has requested I'm not even going to go near: He wants a search on the entire site on keywords found in the current news selection. I think I'll go and lie down for a bit before I go there...
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: This must be really easy: How does a template know where it is?

Post by tsw »

not tested

{capture name="mypagecapture" assing="mypage} {page} {/capture}
{menu start_page=$mypage}

and you could try with {menu start_page=$page} directly (cant remember if its assigned to variable or not :)

hope this helps
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: This must be really easy: How does a template know where it is?

Post by Ted »

Yes, it's assigned to a variable in index.php, so {$page} or {menu start_page=$page} should work.
AndyHolyer

Re: This must be really easy: How does a template know where it is?

Post by AndyHolyer »

Really, really close. Now if I could just work out how to supress the display of the element itself in the menu, and just display the children....
User avatar
chead
Forum Members
Forum Members
Posts: 63
Joined: Tue Feb 06, 2007 4:01 am

Re: This must be really easy: How does a template know where it is?

Post by chead »

If you'd just like to hide that element, you could use CSS:

.currentpage{display:none;}

Alternatively, to actually remove the menu item from the HTML and not just hide it with CSS, you could edit the minimal_menu.tpl file (or a copy of it if you're using the menu elsewhere). Where the template reads:

{if $node->current == true}
url}" class="currentpage"{if $node->target ne ""} target="{$node->target}"{/if}> {$node->menutext}

Replace the second line with a comment line such as:

{* show nothing *}
Locked

Return to “Layout and Design (CSS & HTML)”