Path

ez.no / exponential / documentation / customization / custom design / examples / creating a navigation path


Creating a navigation path

With some help from the demo site and Bruce Morrison:

{section show=ne($node.node_id,21)}

<h1 class="contenttitle">{$node.name}</h1>

<h2 class="crumbs">

       <a href="/">Home</a>

       {section name=Path loop=$module_result.path offset=2 max=-1}

               <span style="color: black"> > </span> <a href={$Path:item.url|ezurl}>{$Path:item.text}</a>

       {/section}

 

</h2>

{/section}

The $module_result.path is an array. I skip the first item (offset=2) as it's the name of home folder which is in my case something else then "home". I also skip the last item (which is the current page and it's shown in the above it already.) As I don't like the crumbs on the homepage, I use the show=ne($node.node_id,21) to hide it on the home node (who's ID is 21)

as a result this will show something like:

My Page

home > folder

Comments

Why the original navigation trail suggestion doesn't work - and a fix

The original suggestion fails because the "max" parameter doesn't use relative offsets (eg "-1"). The fix is to pass the count of the number of elements in the path array and subtract off 2 (1 for the last element and 1 for the initial element, which is skipped). A working example follows:

{section show=ne($node.node_id,101)}
<div id="navtrail">
<div class="crumbs">
<a href={"/"|ezurl} title="Click here to go back...">Home</a>
{section name=Path loop=$module_result.path offset=1 max=$module_result.path|count|sub(2) }
<span> / </span> <a href={$Path:item.url|ezurl} title="Click here to go back...">{$Path:item.text}</a>
{/section}
</div>
</div>
{/section}

Creating a navigation path - did not work

my version to create a navigation part:

{* Navigation Path *}
<h3>
<a href="/">Home</a>

{let count=$module_result.path|count offset=2 sub=1}
{let var=sub( $count, $offset, $sub ) }

{section name=Path loop=$module_result.path
offset=$offset
max=$var }
<span style="color: black"> > </span>
<a href={$Path:item.url|ezurl}>{$Path:item.text}</a>
{/section}
{/let}

</h3>
{*{/section}*}
</div>
{* end navigation path*}

this will help

$module_result.path
is the key

you will find all info in it.

"home" in this case is the name of the siteroot folder it can be translated for every language

in this case I would call it "english" and translate it with the name of each other language

Make it dynamic?

Is there any way to make the hard coded "Home" link dynamically assigned so that it could, for example change based on the language being used to view the page?

Thanks.
RWW

Log in or create a user account to comment.

Contents

Customization

Access control
Exponential API Documentation
Content structure
Custom design
    User specified parameters
    Template variables set by Exponential
    Introduction
    Variables, arrays and objects
    Node
    Database connectivity
    Sections
    File placement
    Override templates
    node_view_gui
    Pagination
    Caching
    Stylesheets
    Pagelayout
    Printable pages
    Examples
       Template language
       Creating a navigation path
       Common template issues
Components
Tips & Tricks
Troubleshooting


Created

16/04/2003
8:57:34 pm
by Jan Borsodi

Last updated

08/07/2003
1:26:45 pm
by B�rd Farstad

Authors

Jan Borsodi
B�rd Farstad



This page is part of the Exponential documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.