Forums / Setup & design / Main node name in the left menu

Main node name in the left menu

Author Message

Remi Lacasse

Thursday 19 October 2006 2:18:17 pm

Hello,

How can I get on the left menu the name of the selected item of the top menu item selected followed by the childs of that node ?

Example:

Top menu: Home - News - Contact us

If I select News, I want to get the left menu showing:

News
Sub-menu 1
Sub-menu 2

I know that I have to add code in the flat_left.tpl copied in the override folder of my site What should be the code underof the first <li> in that template ?

I tried with different code but I got the parent's name instead of the main node name.

Thank you for your help

Best regards,
Rémi

Claudia Kosny

Friday 20 October 2006 3:27:05 am

Hi Remi

I am not sure whether the problem exactly. Do you want that the other nodes on the main level like 'home' and 'contact us' are not displayed on the right side or do you have problems showing the children of the news node?

If the children are not displayed this might be because of the settings in the menu.ini of your site access. By default only folders are displayed (although this might depend on the installed package, I am not sure). Just add your class identifiers to the leftidentifierlist, clear the cache and try again.

If you only want to display the selected main node and its children you could maybe add a depth skip of 1 to the treemenu and then add the link to the main node manually on top of the menu. Or do without the depth skip but check for each node on which level it is and filter all except the current node on the first level.
I am not sure whether this would have the desired result - I usually use my own menus and am not very familiar with the treemenu operator.

If necessary post your code, I will have a look at it this evening.

Greetings from Luxembourg

Claudia

Remi Lacasse

Friday 20 October 2006 12:40:42 pm

Thank you Claudia for your fast answer.

Sorry if I wasnn't clear enough. Anyway, you exactly got what I need in your following paragraph:

'If you only want to display the selected main node and its children you could maybe add a depth skip of 1 to the treemenu and then add the link to the main node manually on top of the menu'

The first suggestion is already done and it works fine.
About adding the main node manually, is where I haven't found a solution yet.
Thank you again to help me on that topic.

Best regards from Canada,
Rémi

Remi Lacasse

Friday 20 October 2006 12:46:22 pm

Hello Claudia,

You can see exactly the kind of menu I would like to get on this site:

http://www.ccts.com.au/

Best regards,
Remi

Claudia Kosny

Friday 20 October 2006 3:30:12 pm

Hi Remi

The selected top level node is usually the second node in the path of the currently viewed node. So just check that such a node exists and fetch the data:

{if and(is_set($module_result.path),
         $module_result.path|count()|ge(2))}
 {* arrays are zero based, thus the second entry has the array key 1 *}
 {def $pathItem = $module_result.path['1']}
 {* if we currently view this node, the url_alias of pathItem is set to false so we need to fetch it from $module_result.content_info *}
 {if $pathItem.url_alias}
  <a href={$pathItem.url_alias|ezurl()} title="{$pathItem.text}">{$pathItem.text}</a>
 {else}
  <a href={$module_result.content_info.url_alias|ezurl()} title="{$pathItem.text}">{$pathItem.text}</a>
 {/if}
{/if}

Ok now we have the link to the desired node which you just need to place on a good point in the menu.
As far as I recall the flat_left template the treemenu is created as an unordered list. In this case you just need to add an additional list element around it:

<ul>
 <li>...add here the link we just created
  {* Add the whole treemenu in there now, I think it starts with an {let... tag *}
 {* close the li and ul again *}
 </li>
</ul>

Please note that you should add the opening and closing ul and li only if there is a link to the selected top level node (the code above will most likely not work if you view something that is not a node, e.g the shop).

Alternatively just add the new link as an heading on top of the treemenu or whatever fits into your html structure.

As usual the code above is not tested. If you have problems just ask.

Greetings from Luxembourg

Claudia