For a recent project I had to tweak the presentation of the document tree.
I wanted to get more information about a document while hovering over it. I added the following items:
* "description"
* "templatename" and
* "templateId"
On top of that I added a class to each document representing the template used.
Example:
* template9 or
* template4.
The idea was to change icons in the document tree so they represent the template used.
Have a look at the attached screenshot to see the results.
To this end I have hacked a few lines into
core/model/modx/processors/resource/getnodes.php
The changes are in line:
Line 44-60
$c->select(array(
'id'
,'pagetitle'
,'longtitle'
,'alias'
,'description'
,'parent'
,'published'
,'deleted'
,'isfolder'
,'menuindex'
,'menutitle'
,'hidemenu'
,'class_key'
,'context_key'
,'template' // pepebe: add template to list of available information
));
84-88
/* pepebe: Get a list of available templates and their properties */
$templateProperties = $modx->getCollection('modTemplate');
/* end pepebe */
139-141
/* pepebe add templatenumber to class */
$class .= ' template'.$item->template;
/* end pepebe */
143-159
/* pepebe enhance tooltip information */
$qtip = '<dl>';
if ($item->longtitle != '') {
$qtip .= '<dt>Longtitle:</dt><dd>'.strip_tags($item->longtitle).'</dd>';
}
if ($item->description != '') {
$qtip .= '<dt>Description:</dt><dd>'.strip_tags($item->description).'</dd>';
}
if ($item->template != '') {
foreach ($templateProperties as $templateProperty) {
if($templateProperty->get('id') == $item->template){
$qtip .= '<dt>Template:</dt><dd>'.strip_tags($templateProperty->get('templatename')).' ('.strip_tags($item->template).')</dd>';
}
}
}
$qtip .= '</dl>';
/* end pepebe*/
I added a few lines to the bottom of manager/templates/default/css/modx-min.css
div.template8 .x-tree-node-icon {background-image: url("../images/restyle/icons/calender.png")!important;}
div.template9 .x-tree-node-icon {background-image: url("../images/restyle/icons/computer.png")!important;}
(Yeah, I know !important is bad, but it didn’t work without that.)
The new icons are just an examples, but I think you get the idea...
The changes are for MODx Revolution 2.0.5-pl (traditional). You can download the the file below. Don’t forget to remove the .txt extension...
Questions:
1. I’m new to revo, are there any ways to do that without messing around with the core?
2. It works, but is there room for improvement?
Regards,
pepebe