Wayfinder 1.0

Totally refactored from original DropMenu nav builder to make it easier to create custom navigation by using chunks as output templates. By using templates, many of the paramaters are no longer needed for flexible output including tables, unordered- or ordered-lists (ULs or OLs), definition lists (DLs) or in any other format you desire.

Install Instructions:

  1. Copy the contents of the file snippet.wayfinder.tpl.php into a new snippet named Wayfinder.
  2. Create a new folder under assets/snippets named wayfinder.
  3. Copy the file wayfinder.inc.php into the newly created folder.

Parameters:

Parameter Description Default
&startId the starting point for the menu (document ID) current docId
&level the depth to build the menu (0 goes through all levels) 0
&ignoreHidden ingore the show in menu checkbox for documents and include them in the menu FALSE
&ph name of a placeholder to set instead of directly retuning the output results FALSE
&debug turn on debug mode for extra troubleshooting FALSE
&hideSubMenus set true to only output the active submenu FALSE
&removeNewLines set true to remove newline characters from output FALSE
&textOfLinks what database field do you want the actual link text to be? Use the following values: menutitle, id, pagetitle, description, parent, alias, longtitle, introtext menutitle
&titleOfLinks what database field do you want the title of your links to be? Use the following values: menutitle, id, pagetitle, description, parent, alias, longtitle, introtext pagetitle
&rowIdPrefix if set, creates a unique id for each item (id is value of rowIdPrefix + docId) FALSE
&useWeblinkUrl if set to TRUE the link specified in the weblink will be output to the placeholder [+wf.link+] TRUE
&showSubDocCount if set to TRUE the number of documents in each folder will be output to the placeholder [+wf.subitemcount+] FALSE
&sortOrder Allows the menu to be sorted in either ascending or descending order. ASC
&sortBy Specify any of the following fields to sort the menu: id, menutitle, pagetitle, introtext, menuindex, published, hidemenu, parent, isfolder, description, alias, longtitle, type, template menuindex
Template Chunks for Menu Layout
&outerTpl the template chunk for the outer most container
placeholders:
[+wf.classes+] - where classes specifed will be inserted (includes class=" ")
[+wf.classnames+] - outputs the just the class names (without class=" ")
[+wf.wrapper+] - where inner content will be inserted
example: <ul id="topnav"[+wf.classes+]>[+wf.wrapper+]</ul>
« See Example
&rowTpl the template chunk for the row items
placeholders:
[+wf.classes+] - where classes specifed will be inserted (includes class=" ")
[+wf.classnames+] - outputs the just the class names (without class=" ")
[+wf.link+] - the href value for your link
[+wf.title+] - text for the link title
[+wf.linktext+] - text for the link dispaly
[+wf.wrapper+] - where to insert a submenu
[+wf.id+] - where to insert unique id
[+wf.attributes+] - where to insert link attributes
[+wf.docid+] - the document identifier for the current item
[+wf.subitemcount+] - displays the number of items in a folder
[+wf.description+] - output the description field
[+wf.introtext+] - output the introtext field
example: <li[+wf.id+][+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]" [+wf.attributes+]>[+wf.linktext+]</a>[+wf.wrapper+]</li>
« See Example
&parentRowHereTpl the template chunk for the current document if it is a folder
placeholders: same as rowTpl
example: <li[+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]»</a>[+wf.wrapper+]</li>
none
&parentRowTpl the template chunk for any document that is a folder
placeholders: same as rowTpl
example: <li[+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]»</a>[+wf.wrapper+]</li>
none
&hereTpl the template chunk for the current document
placeholders: same as rowTpl
example: <li[+wf.classes+]><span>[+wf.linktext+]</span>[+wf.wrapper+]</li>
none
&innerTpl the template chunk for the any subfolders listed
placeholders: same as outerTpl
example: <ul[+wf.classes+]>[+wf.wrapper+]</ul>
none
&innerRowTpl the template chunk for the row items in a subfolder
placeholders: same as rowTpl
example: <li[+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a>[+wf.wrapper+]</li>
none
&innerHereTpl the template chunk for the current document if in a subfolder
placeholders: same as rowTpl
example: <li[+wf.classes+]><span>[+wf.linktext+]</span>[+wf.wrapper+]</li>
none
&activeParentRowTpl the template chunk for the items that are folders and are currently active in the tree
placeholders: same as rowTpl
example: <li[+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a>[+wf.wrapper+]</li>
none
&categoryFoldersTpl the template chunk for category folders, category folders are determined by setting the template to blank or by setting the link attributes field to rel="category"
placeholders: same as rowTpl
example: <li[+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a>[+wf.wrapper+]</li>
none
Class names to be assigned
&firstClass CSS class denoting the first item at a given menu level none
&lastClass CSS class denoting the last item at a given menu level last
&hereClass CSS class denoting the "you are here" state all the way up the chain here
&selfClass CSS class denoting the "you are here" state for current doc only none
&parentClass CSS class denoting the menu item is a folder (has children) parent
&rowClass CSS class denoting each output row none
&levelClass CSS class denoting each output rows level, the level number will be added to the specified class (i.e. level1, level2, level3, etc...) none
&outerClass CSS class for the outer template none
&innerClass CSS class for the inner template none
&webLinkClass CSS class for weblinks none
CSS & Javascript to include with menu
*&cssTpl name of a chunk containing css you would like added to the page FALSE
*&jsTpl name of a chunk containing javascript you would like added to the page FALSE

* - uses regClientCSS or regClientStartupScript, this may not work correctly unless you have patched the parser with this: http://modxcms.com/forums/index.php/topic,1942.msg18783.html#msg18783


Example Call:

[[Wayfinder? &startId=`0`]]

[[Wayfinder? &startId=`0` &level=`3` &hideSubMenus=`1` &outerTpl=`wfOuter` &rowTpl=`wfRow` &hereTpl=`wfHere`]]

Change Log

Revision Author Date Description
1396 kjaebker 3:45:10 PM, Monday, October 23, 2006 - Updated database query so sorting works correctly for MySql 4.1.12 users
- Added parameters for determining sortBy and sortOrder
- Added placeholders for introtext and description
- Added ability to show count of docs in a folder with new placeholder
- Removed some code from snippet into class for easier maintenance
1396 kjaebker 3:48:10 PM, Tuesday, September 12, 2006 updated to include version checking so it works with releases prior to 0.9.5
1369 kjaebker 4:30:45 PM, Wednesday, September 06, 2006 Removed noClassTag parameter and added separate placeholder for class names
1368 kjaebker 4:17:19 PM, Wednesday, September 06, 2006 - Added category support, with additional template
- Added active parent template
- Added docid placeholder for output of docid
- Added noClassTag param to allow for output of just class names
1360 kjaebker 4:12:41 PM, Tuesday, September 05, 2006 fix for last item detection
1327 kjaebker 10:12:23 PM, Monday, August 21, 2006 Updated to add parameter for using content for url or using docId for weblinks.
1300 kjaebker 3:23:59 PM, Wednesday, August 16, 2006 - Added support for link_attributes
- Made custom version of getActiveChildren in class
- Added class for weblinks
- Weblinks will display the content link instead of link to id
1233 kjaebker 3:35:58 PM, Friday, August 04, 2006 Added parentRowHereTpl template, added selfClass, updated docs
1228 kjaebker 4:25:55 PM, Thursday, August 03, 2006 fixed parent class bug, added unique id param, removed ultimateparent code