
Aug 09
Changing MODx Managers Document Tree View Nodes
Yesterday I stumbled upon MODx, an open source content management system. It wasn’t the first time I’ve come across it but I’m really enjoying it and am using it on my current project.
A small niggle I found was the document tree view that’s displayed in the left hand side of the manager. It displays the “resources” title (aka the page title) which is bit confusing like shown below.
After realising that displaying the alias would be a lot more helpful, in this case, I had a quick browse through the source. You can make it display the alias by replacing a few variables inside the while loop in /modx_directory/manager/frames/nodes.php. In the example I’ve simply changed $pagetitle with $alias.
As an example I changed:
1 2 3 4 5 6 7 8 | while(list($id,$pagetitle,$parent,$isfolder,$published,$deleted,$type,$menuindex,$hidemenu,$alias,$contenttype,$privateweb,$privatemgr,$hasAccess) = mysql_fetch_row($result)) { $pagetitle = htmlspecialchars($pagetitle); $protectedClass = $hasAccess==0 ? ' protectedNode' : ''; $pagetitleDisplay = $published==0 ? "<span class=\"unpublishedNode\">$pagetitle</span>" : ($hidemenu==1 ? "<span class=\"notInMenuNode$protectedClass\">$pagetitle</span>":"<span class=\"publishedNode$protectedClass\">$pagetitle</span>"); $pagetitleDisplay = $deleted==1 ? "<span class=\"deletedNode\">$pagetitle</span>" : $pagetitleDisplay; $weblinkDisplay = $type=="reference" ? ' <img src="'.$_style["tree_linkgo"].'">' : '' ; $pageIdDisplay = '<small>('.($modx_textdir ? '‏':'').$id.')</small>'; |
To:
1 2 3 4 5 6 7 8 | while(list($id,$pagetitle,$parent,$isfolder,$published,$deleted,$type,$menuindex,$hidemenu,$alias,$contenttype,$privateweb,$privatemgr,$hasAccess) = mysql_fetch_row($result)) { $pagetitle = htmlspecialchars($pagetitle); $protectedClass = $hasAccess==0 ? ' protectedNode' : ''; $pagetitleDisplay = $published==0 ? "<span class=\"unpublishedNode\">$alias</span>" : ($hidemenu==1 ? "<span class=\"notInMenuNode$protectedClass\">$alias</span>":"<span class=\"publishedNode$protectedClass\">$alias</span>"); $pagetitleDisplay = $deleted==1 ? "<span class=\"deletedNode\">$alias</span>" : $pagetitleDisplay; $weblinkDisplay = $type=="reference" ? ' <img src="'.$_style["tree_linkgo"].'">' : '' ; $pageIdDisplay = '<small>('.($modx_textdir ? '‏':'').$id.')</small>'; |
And the result:
MODx Revolution
In Revolution you can change the document tree node from System > System Settings. In the Filter text box at the top right type in resource_tree and hit enter. To set the treenode values to their alias, for example, set the value of resource_tree_node_name to alias.
The process for editing document tree nodes in MODx revolution is different. The file you need to edit is /core/model/modx/processors/resource/getnodes.php. Here is an example for using the document alias around line 148.
1 2 3 4 5 6 7 8 9 10 11 12 13 | // Document Tree Node Change if(!$item->alias) { // If no alias is set on the page set an alternative to fall back on $documentNodeText = strip_tags($item->$nodeField); } else { // Use the document alias in the document tree $documentNodeText = strip_tags($item->alias); } $itemArray = array( //'text' => strip_tags($item->$nodeField).' <span dir="ltr">('.$item->id.')</span>', 'text' => $documentNodeText.' <span dir="ltr">('.$item->id.')</span>', |
Bookmark or share this page:
Related posts:
MSN Contact: contact [at] danielgibbs.net
Dan Gibbs is a web developer, designer and SEO consultant involved in devon web design.








Mike 28 June 2010 11:19 pm
Cool, that’s a good idea
Gibbs 30 March 2011 5:21 pm
Updated to include a small piece for MODx Revolution.
eetv 28 December 2011 3:44 pm
Great tip, using revolution, thank you!