Personal tools
FAQ/Layout and Design/SubMenu Heading
From CMSMS
This page in: English - Deutsch - Français - Svenska - Русский - Norsk - Polski - Nederlands - Español - Lietuvių
Sub Menu Heading
The standard EllNav Horiz/Vert set of templates has a horizontal main menu and then a secondary vertical menu. Sometimes its nice to add a heading to the vertical menu to place it in context on the page. This article is taken from a []http://forum.cmsmadesimple.org/index.php/topic,4705.msg26467.html#msg26467 forum post]] which describes a solution.
The steps required are:
- Create a new user-defined tag by going to Extensiosn -> User-Defined Tags
- Click on Add User Defined Tag
- Provide a tag name of parent_title
- Provide code as follows:
global $gCms;
$db =& $gCms->GetDb();
$vars =& $gCms->variables;
$query = "SELECT content_name FROM "
.cms_db_prefix()
."content WHERE content_id = (SELECT parent_id FROM "
.cms_db_prefix()
."content WHERE content_id = '"
.$vars['content_id']
."');";
$dbresult = $db->Execute($query);
if ($dbresult && $dbresult->RowCount() > 0) {
$row = $dbresult->FetchRow();
echo $row['content_name'];
} else {
echo $vars['pageinfo']->content_menutext;
}
Submit, and the tag is now ready for use in any templte.
For example, you can add this to the EllNav Horiz/Vert L 1col template (and likely also the EllNav Horiz/Vert L 2col template by matching the code below with the template code:
<!-- Start Content (Navigation and Content columns) -->
<div id="content" class="clearfix">
<!-- Start Navigation -->
<div id="menu_vert">
<h2 class="accessibility">Sub Navigation</h2>
<h2>{parent_title}</h2>
{cms_module module='menumanager' template='ellnav-accessible.tpl' start_level='2' collapse='1'}
<hr />
</div>
<!-- End Navigation -->
Notice the new line inserted which contains: {parent_title}.
Now open a page that uses this template, and, voila!, there is now a heading above the submenu that matches the first level menu.
Using the Menu Manager to Create Sub Menu Headings
Another way to create a menu header is to create a simplified template in the menu manager. Your header could be a styled text label or an image that changes depending on which section you're in.
Make a new menu template just for the header. The code for this header-only menu template is:
{if $count > 0}
{foreach from=$nodelist item=node}
{if $node->current == true or $node->parent == true}
{* ADD WHAT YOU WANT TO DISPLAY AS A HEADER HERE. *}
{/if}
{/foreach}
{/if}
In this menu template, replace the comment line with the HTML/Smarty code that displays what you want in your menu header. You can make your own, or just copy/paste from your side menu template. A few examples are shown below.
In your page template, add {menu start_level ='1' number_of_levels='1'} where you want the header to appear — usually just before your side {menu}. Styling and formatting of the header can be included in either the menu template or page template.
Examples:
- For just the text, use "$node->menutext" in your menu template.
- To use an image, use "<img src='__your_path__/{$node->alias}.jpg'/ alt="{$node->menutext}">". Simply name your header images after the page aliases of the top-level pages change __your_path__ to the folder where the images are saved.
