Well I too required this as I wanted to Make Some simple blog navigation, especially on containers with alot of hidden from menu pages, here is what i did maybe someone could expand on it further.
Snippets Used (not all are necessary in the end) but they are all 3 good to have in your repertoire, id install em anyways they are tiny and quick to set up.
GetField 1.3beta -
http://www.modxcms.com/getField-1.3-beta-1189.htmlUltimateParent 1.3 -
http://modxcms.com/UltimateParent-643.htmlFirstChildRedirect 1.1-
http://www.modxcms.com/FirstChildRedirect-1.1-840.htmlNow Continuing in the work of the above posters.......both methods listed here seem to work, however i cleaned it up a bit.
I created the chunks as per pleth's post above
{{getFieldid}} == [!GetField? &docid=`[*parent*]` &field=`id`!]
{{getFieldpt}} == [!GetField? &docid=`[*parent*]` &field=`pagetitle`!]
{{getFieldlink}} ==<a href="[~{{getFieldid}}~]" title="{{getFieldpt}}">{{getFieldpt}}</a>
Regardless of FirstChildRedirect in the parent folder or not, the chunk {{getFieldlink}} was able to return the appropriately titled Parent Link.
Alternatively, you could use lesur's Method and create a new snipped called
[[ParentLink]] ==
<?php
$id=$modx->documentObject['id'];
$fid = $modx->getParent($id,1,'id');
if(is_array($fid))
$bingo=implode(" ", $fid);
if ($bingo != "") {
$flpt=$modx->getChunk('getFieldpt');
return "<a href=\"[~$bingo~]\" title=\"$flpt\">$flpt</a>";
}
else
return "$fid";
?>
This also Returns the same a result as per pleth's post.
Which one is cleaner?
I dunno I'm no expert but they both work.
Moving on, I created a new Chunk called
{{BlogNav}}
This chunk will be used to provide basic navigation between all hidden documents in a single directory as well *only* that document's immediate parent. This allows you to have navigation between individual pages within a blog without the 99 blog posts form a trip in the main menu, or the clutter of ditto calls on each page yet it still provides the navigation, even if the pages are hidden from the main menu.
For Instance it will return this, regardless of where the documents reside in the main site's hierarchy, even if they are hidden:
- MY Blog
- Post1
- Post2
- Post3
- Post 4
- Post 99
So to finish it off this is the master chunk you need:
{{BlogNav}} ==
<div id="blognav">
<ul>
<li>{{getFieldlink}}
[!Wayfinder? &startId=`[*parent*]` &ignoreHidden=`true`!]
</li>
<li>[[ParentLink]]</li>
</ul>
</div>
I used both {{getFieldlink}} & [[ParentLink]] To show it could be done either way or both.
Now Add some CSS Styling:
#blognav {
text-align:center;
}
#blognav li, #blognav ul {
display:inline;
margin:0px;
list-style-type:none;
}
Now put the {{BlogNav}} call in the bottom of any document or add it to your template and you will get a nice navmenu output in the bottom of your blog post in the same order as your menu sorting within modx...just like i used on my site while i was in Hawaii:
http://www.mmayukon.ca/training/blogs/mauiblog/mauitease.htmlSide Notes and Ideas for future improvement:The next step would be to combine this with pagination or Breadcrumbs somehow. I wouldn't know how to do that though. Also, Another Interesting Result of this experiment is that I Made another Chunk using getfield that returns the parent 2 steps up from the source documents ID.
This could also be useful in certain circumstances I think.
I called it:
{{DoubleParent}} == [!GetField? &docid=`[*parent*]`&field=`id`&parent=`1`&parentLevel=`1`!]