eZpedia : The Free eZ Publish CMS Documentation Encyclopedia

Snippet: Template logic to exclude a content object node from menus

Table of contents:

Or, Looking for a way to hide a content?

Problem

I have many folders in the root eZ publish content tree (or elsewhere) which I do not want to be displayed in the menu.

Is there any way to add a folder to to eZ publish without it showing up in the top menus?

Solution

Using the eZ publish administrator, select Setup→Classes.

Edit your folder class and add checkbox called “Show in menu” (show_in_menu) By default checkbox is checked.

Then replace code in 'design/base/templates/menu/double_top.tpl' If you using double top menu.

{section show=eq( sum( $menu.index, 1 ), $menuitems|count )}
                        <li class="last {eq( $module_result.path[1].node_id, $menu.node_id )|choose( '', 'selected' )}"><div class="spacing"><a href={$menu.url_alias|ezurl}>{$menu.name|wash}</a></div></li>
                {section-else}
                    <li {eq( $module_result.path[1].node_id, $menu.node_id )|choose( '', 'class="selected"' )}><div class="spacing"><a href={$menu.url_alias|ezurl}>{$menu.name|wash}</a></div></li>
                {/section}

With

{section show=$menu.object.data_map.show_in_menu.data_int}
                {section show=eq( sum( $menu.index, 1 ), $menuitems|count )}
                        <li class="last {eq( $module_result.path[1].node_id, $menu.node_id )|choose( '', 'selected' )}"><div class="spacing"><a href={$menu.url_alias|ezurl}>{$menu.name|wash}</a></div></li>
                {section-else}
                    <li {eq( $module_result.path[1].node_id, $menu.node_id )|choose( '', 'class="selected"' )}><div class="spacing"><a href={$menu.url_alias|ezurl}>{$menu.name|wash}</a></div></li>
                {/section}
        {/section}

If you usign design/base/templates/menu/flat_top menu replace

{section show=eq( sum( $menu.index, 1 ), $menuitems|count )}
                <li class="last {eq( $module_result.path[1].node_id, $menu.node_id )|choose( '', 'selected' )}"><div class="spacing"><a href={$menu.url_alias|ezurl}>{$menu.name|wash}</a></div></li>
                {section-else}
                <li {eq( $module_result.path[1].node_id, $menu.node_id )|choose( '', 'class="selected"' )}><div class="spacing"><a href={$menu.url_alias|ezurl}>{$menu.name|wash}</a></div></li>
                {/section}

With

{section show=$menu.object.data_map.show_in_menu.data_int}
                {section show=eq( sum( $menu.index, 1 ), $menuitems|count )}
                <li class="last {eq( $module_result.path[1].node_id, $menu.node_id )|choose( '', 'selected' )}"><div class="spacing"><a href={$menu.url_alias|ezurl}>{$menu.name|wash}</a></div></li>
                {section-else}
                <li {eq( $module_result.path[1].node_id, $menu.node_id )|choose( '', 'class="selected"' )}><div class="spacing"><a href={$menu.url_alias|ezurl}>{$menu.name|wash}</a></div></li>
                {/section}
{/section}

If show_in_menu flag is set to true (checked) item is show in menu.

Special thanks to participants: Negin Javadi, Gabriel Ambuehl, Lukasz Serwatka

References

Article provided by eZpedia

All text is available under the terms of the GNU Free Documentation License

Powered by eZ Publish Community Project 4.2011

Hosted by Swiss eZ Publish partner YMC