I 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.



My Favorite MODx Resources | Greg Smart says:
[...] It allows you to look up the document tree and retrieve fields from parent documents. In a previous post I outlined my method for piecing together code from multiple getField call [...]
July 3rd, 2009 at 1:41 pm
I'm enjoying your blog greatly. When I saw this post, it reminded me of a very similar problem I had. I thought you might be interested in how I solved the problem.
http://modxcms.com/forums/index.php/topic,26615...
November 27th, 2009 at 11:56 am
Great to hear! Check out the comments on this post, they were very helpful: http://www.gregorysmart.com/2009/11/03/a-modx-n...
November 27th, 2009 at 5:33 pm
I'm enjoying your blog greatly. When I saw this post, it reminded me of a very similar problem I had. I thought you might be interested in how I solved the problem.
http://modxcms.com/forums/index.php/topic,26615...
November 27th, 2009 at 5:56 pm
Great to hear! Check out the comments on this post, they were very helpful: http://www.gregorysmart.com/2009/11/03/a-modx-n...
November 27th, 2009 at 11:33 pm
I'm havig trouble all output is empty. Do I need to install the GetField Snippet? I just did, same empty output…
May 2nd, 2010 at 7:13 pm
Yes, install the GetField snippet. If you are not getting any output try changing the cache [[]] or [!!]. You can also try changing the page caching where the snippet call is located.
May 2nd, 2010 at 7:20 pm