On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • 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
      Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
    • pepebe that’s a neat idea and a way to effectively treat templates as a way to identify content types (e.g., blog, press release, etc.). You might file this as a feature request for the future at http://bugs.modx.com/
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • Hi all,
        for a project in Evo I had a similar aim, but not so eager: I just wanted the template name of the document showing up too when hovering on the document in the tree. This is what I did:

        In line 118 of the file [tt]/manager/frames/nodes.php[/tt] insert "[tt]template,[/tt] " .
        So it gets
        $sql = "SELECT DISTINCT template, sc.id, pagetitle,....
        
        In line 134 insert a first parameter "[tt]$template,[/tt] " for [tt]list[/tt] and add the 3 statements following the opening bracket [tt]{[/tt] :
        while(list($template,$id,$pagetitle,$parent,$isfolder,$published,$deleted,$type,$menuindex,
        $hidemenu,$alias,$contenttype,$privateweb,$privatemgr,$hasAccess) = mysql_fetch_row($result))
                {
        $rs=$modx->db->select('templatename',$modx->getFullTableName('site_templates'),"id='$template' ");
        $row=$modx->db->getRow($rs);
        $templatename=$row['templatename'];

        Finally after line 149 add the following:
        $alt.= " ".$_lang['page_data_template'].": ".$templatename;

        That did it.
        ottogal




        • Quote from: rthrash at Dec 20, 2010, 02:44 PM

          pepebe that’s a neat idea and a way to effectively treat templates as a way to identify content types (e.g., blog, press release, etc.). You might file this as a feature request for the future at http://bugs.modx.com/

          Sure,

          Unfortunatley I can’t login anymore. There is no option to retrieve a lost password. Documentation tells me:

          The Lost password link is only displayed if the administrator has activated it.

          Please activate it.

          Regards,

          pepebe
            Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
          • @ ottogal
            Nice one wink
            Saves having to open the doc to see which template it uses.
            Feature request for next Evo version?