MODxI recently began a MODx forum thread looking for community assistance with solving a Wayfinder navigation issue. I was eventually able to tackle the output issue with my own solution (below), but since this thread has been reactivated by someone else asking for my solution I felt it was reasonable to post a version of this here as well.

The Problem

I had a design that required only the output of the current directory structure be displayed as the user navigates through the site. So, if the directory structure looks like this:

Home
About us
    History
    Mission
Contact us
    Telephone
    Address

and the user is in About Us, then the output should be:

About us
    History
    Mission

conversely, if the user is in Contact Us the output would be:

Contact us
    Telephone
    Address

The problem here is the output generated by the Wayfinder snippet does not provide the ability to isolate all the elements in this manner and still retain the directory name as a navigational link.

The Solution

Create a chunk, {{getFieldid}} with the snippet call:

[!GetField? &docid=`[*parent*]` &field=`id`!]

then create another chunk, {{getFieldpt}} with the snippet call:

[!GetField? &docid=`[*parent*]` &field=`pagetitle`!]

Once the parent page title and parent document id is isolated a third chunk could then be created, {{getFieldlink}} to contain the combined elements and generate a link to the parent directory in which the user is located:

<a href="[~{{getFieldid}}~]" title="{{getFieldpt}}">{{getFieldpt}}</a>

Next, call in the {{getFieldlink}} chunk above a Wayfinder call,

[!Wayfinder? &startId=`[[UltimateParent? &topLevel=`1`]]`!]

and then style the output with CSS.

blog comments powered by Disqus