MODxI really love the MODx community, I am always surprised at how active it is and how much assistance it provides. If you are thinking about learning MODx I highly recommend you sign up in their forums.

This is actually a follow-up to an earlier post of mine, Navigation – Wayfinder & getField snippets. In this post I outlined a self-developed method for creating links in MODx based on parent document fields. Well, it looks like dsumanik has posted an updated solution to solve this issue.

While I haven’t had the opportunity to test it out, the PHP appears sound at first glance and I sure wouldn’t want to lose track of a good MODx snippet. He is calling it the ParentLink snippet. The code is below.

<?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";


?>