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:

