We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28353
    • 28 Posts
    Hey Guys,

    I remember when i first implemented modx onto a site and created pages/documnets, the documents in the document tree were being named from the menu title. How come its not like that anymore. What is the point of the menu title field if its not going to be on the tree menu? how can i change this to reflect that?

    thanks
      • 3749
      • 24,544 Posts
      I could be wrong, but I think the tree has always used the pagetitle field. Is it possible that the menu title and pagetitle were the same in the cases you’re remembering.

      The menu title field is there so that Snippets like Wayfinder and Ditto can use the menu title in menus and aggregated displays and users can use the [*menutitle*] tag wherever they like.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        The menu title is a relatively recent addition; I’m not sure exactly when it was added though. So originally, there was only the page title to use.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 28353
          • 28 Posts
          thanks for the reply! version 0.9.6.3 goes off the menutitle but if there is no menutitle present then it falls back to the pagetitle. how can i set it up to do this again, because right now it just goes off the pagetitle. i have pagetitles that are long. Example: fhadsfsdajk | fhaskfdhsalj | site name. I dont want the tree menu to reflect that. Is there anyway to change this to menutitle?

          thanks
            • 28353
            • 28 Posts
            im logged into an old site that has version 0.9.6.3 and it has menutitle and it does what i explained in my previous post. it goes off the menutitle and if its not there then it uses the pagetitle.
              • 3749
              • 24,544 Posts
              Interesting. You don’t have ManagerManger installed in 9.6.3 do you?

              I don’t have a copy of .9.6.3. I looked at an older version of MODx (9.6.1 I think) and I don’t see any references to menutitle in the tree code (except in ManagerManager).

              I think the code would be in manager/frames/nodes.php or possibly manager/frames/tree.php

              I don’t see an easy fix (unless ManagerManager would do it) and changes there might have some unpleasant side effects.

              Someone else may have a better idea and you could always file it in Jira through the link at the top of this page as a feature request (with an associated System Setting to turn on that feature).


                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 8522
                • 145 Posts
                Hi

                I made a few modifications on /manager/frames/nodes.php of modx evolution 1.0.1. Each line that I changed is tagged with "// menuTitleMod"

                It needed one check if menutitle is empty, then it switches to pagetitle for this node.

                changes are on lines 100, 123, 132, 136-138


                <?php
                /**
                 *  Tree Nodes
                 *  Build and return document tree view nodes
                 *
                 */
                if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the MODx Content Manager instead of accessing this file directly.");
                
                    // save folderstate
                    if (isset($_GET['opened'])) $_SESSION['openedArray'] = $_GET['opened'];
                    if (isset($_GET['savestateonly'])) {
                        echo 'send some data'; //??
                        exit;
                    }
                
                    $indent    = $_GET['indent'];
                    $parent    = $_GET['parent'];
                    $expandAll = $_GET['expandAll'];
                    $output    = "";
                    $theme = $manager_theme ? "$manager_theme/":"";
                
                    // setup sorting
                    if(isset($_REQUEST['tree_sortby'])) {
                        $_SESSION['tree_sortby'] = $_REQUEST['tree_sortby'];
                    }
                    if(isset($_REQUEST['tree_sortdir'])) {
                        $_SESSION['tree_sortdir'] = $_REQUEST['tree_sortdir'];
                    }
                
                    // icons by content type
                
                    $icons = array(
                        'application/rss+xml' => $_style["tree_page_rss"],
                        'application/pdf' => $_style["tree_page_pdf"],
                        'application/vnd.ms-word' => $_style["tree_page_word"],
                        'application/vnd.ms-excel' => $_style["tree_page_excel"],
                        'text/css' => $_style["tree_page_css"],
                        'text/html' => $_style["tree_page_html"],
                        'text/xml' => $_style["tree_page_xml"],
                        'text/javascript' => $_style["tree_page_js"],
                        'image/gif' => $_style["tree_page_gif"],
                        'image/jpg' => $_style["tree_page_jpg"],
                        'image/png' => $_style["tree_page_png"]
                    );
                	$iconsPrivate = array(
                	    'application/rss+xml' => $_style["tree_page_rss_secure"],
                	    'application/pdf' => $_style["tree_page_pdf_secure"],
                	    'application/vnd.ms-word' => $_style["tree_page_word_secure"],
                	    'application/vnd.ms-excel' => $_style["tree_page_excel_secure"],
                	    'text/css' => $_style["tree_page_css_secure"],
                	    'text/html' => $_style["tree_page_html_secure"],
                	    'text/xml' => $_style["tree_page_xml_secure"],
                	    'text/javascript' => $_style["tree_page_js_secure"],
                	    'image/gif' => $_style["tree_page_gif_secure"],
                	    'image/jpg' => $_style["tree_page_jpg_secure"],
                	    'image/png' => $_style["tree_page_png_secure"]
                	);
                
                    if (isset($_SESSION['openedArray'])) {
                            $opened = explode("|", $_SESSION['openedArray']);
                    } else {
                            $opened = array();
                    }
                    $opened2 = array();
                    $closed2 = array();
                
                    makeHTML($indent,$parent,$expandAll,$theme);
                    echo $output;
                
                    // check for deleted documents on reload
                    if ($expandAll==2) {
                        $sql = "SELECT COUNT(*) FROM $dbase.`".$table_prefix."site_content` WHERE deleted=1";
                        $rs = mysql_query($sql);
                        $row = mysql_fetch_row($rs);
                        $count = $row[0];
                        if ($count>0) echo '<span id="binFull"></span>'; // add a special element to let system now that the bin is full
                    }
                
                    function makeHTML($indent,$parent,$expandAll,$theme) {
                    	global $modx;
                        global $icons, $iconsPrivate, $theme, $_style;
                        global $modxDBConn, $output, $dbase, $table_prefix, $_lang, $opened, $opened2, $closed2; //added global vars
                
                        $pad = "     ";
                
                        // setup spacer
                        $spacer = "";
                        for ($i = 1; $i <= $indent; $i++){
                            $spacer .= "     ";
                        }
                
                	if (!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) {
                		// This is the first startup, set default sort order
                		$_SESSION['tree_sortby'] = 'menuindex';
                		$_SESSION['tree_sortdir'] = 'ASC';
                	}
                	$orderby = $_SESSION['tree_sortby']." ".$_SESSION['tree_sortdir'];
                
                	// Folder sorting gets special setup ;) Add menuindex and pagetitle
                	if($_SESSION['tree_sortby'] == 'isfolder') $orderby .= ", menuindex ASC, menutitle, pagetitle"; // menuTitleMod
                
                        $tblsc = $dbase.".`".$table_prefix."site_content`";
                        $tbldg = $dbase.".`".$table_prefix."document_groups`";
                        $tbldgn = $dbase.".`".$table_prefix."documentgroup_names`";
                        // get document groups for current user
                        if($_SESSION['mgrDocgroups']) $docgrp = implode(",",$_SESSION['mgrDocgroups']);
                        $showProtected= false;
                        if (isset ($modx->config['tree_show_protected'])) {
                            $showProtected= (boolean) $modx->config['tree_show_protected'];
                        }
                        $mgrRole= (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole']==='1') ? '1' : '0';
                        if ($showProtected == false) {
                            $access = "AND (1={$mgrRole} OR sc.privatemgr=0".
                                      (!$docgrp ? ")":" OR dg.document_group IN ({$docgrp}))");
                        }
                        $sql = "SELECT DISTINCT sc.id, pagetitle, parent, isfolder, published, deleted, type, menuindex, menutitle, hidemenu, alias, contentType, privateweb, privatemgr,
                                MAX(IF(1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? "":" OR dg.document_group IN ({$docgrp})") . ", 1, 0)) AS has_access
                                FROM {$tblsc} AS sc
                                LEFT JOIN {$tbldg} dg on dg.document = sc.id
                                WHERE (parent={$parent})
                                $access
                                GROUP BY sc.id
                                ORDER BY {$orderby}"; // menuTitleMod
                        $result = mysql_query($sql, $modxDBConn);
                        if(mysql_num_rows($result)==0) {
                            $output .= '<div style="white-space: nowrap;">'.$spacer.$pad.'<img align="absmiddle" src="'.$_style["tree_deletedpage"].'"> <span class="emptyNode">'.$_lang['empty_folder'].'</span></div>';
                        }
                
                		// Make sure to pass in the $modx_textdir variable to the node builder
                		global $modx_textdir;
                
                        while(list($id,$pagetitle,$parent,$isfolder,$published,$deleted,$type,$menuindex,$menutitle,$hidemenu,$alias,$contenttype,$privateweb,$privatemgr,$hasAccess) = mysql_fetch_row($result)) // menuTitleMod
                        {
                            $pagetitle = htmlspecialchars($pagetitle);
                            $protectedClass = $hasAccess==0 ? ' protectedNode' : '';
                            $menutitle = $menutitle!='' ? htmlspecialchars($menutitle) : $pagetitle; // menuTitleMod
                            $pagetitleDisplay = $published==0 ? "<span class=\"unpublishedNode\">$menutitle</span>" : ($hidemenu==1 ? "<span class=\"notInMenuNode$protectedClass\">$menutitle</span>":"<span class=\"publishedNode$protectedClass\">$menutitle</span>"); // menuTitleMod
                            $pagetitleDisplay = $deleted==1 ? "<span class=\"deletedNode\">$menutitle</span>" : $pagetitleDisplay; // menuTitleMod
                            $weblinkDisplay = $type=="reference" ? ' <img src="'.$_style["tree_linkgo"].'">' : '' ;
                			$pageIdDisplay = '<small>('.($modx_textdir ? '‏':'').$id.')</small>';
                
                            $alt = !empty($alias) ? $_lang['alias'].": ".$alias : $_lang['alias'].": -";
                            $alt.= " ".$_lang['resource_opt_menu_index'].": ".$menuindex;
                            $alt.= " ".$_lang['resource_opt_show_menu'].": ".($hidemenu==1 ? $_lang['no']:$_lang['yes']);
                            $alt.= " ".$_lang['page_data_web_access'].": ".($privateweb ? $_lang['private']:$_lang['public']);
                            $alt.= " ".$_lang['page_data_mgr_access'].": ".($privatemgr ? $_lang['private']:$_lang['public']);
                
                            if (!$isfolder) {
                                $icon = ($privateweb||$privatemgr) ? $_style["tree_page_secure"] : $_style["tree_page"];
                				$icon = (($privateweb||$privatemgr) && (isset($icons[$contenttype]))) ? $iconsPrivate[$contenttype] : $icons[$contenttype];
                                $output .= '<div id="node'.$id.'" p="'.$parent.'" style="white-space: nowrap;">'.$spacer.$pad.'<img id="p'.$id.'" align="absmiddle" title="'.$_lang['click_to_context'].'" style="cursor: pointer" src="'.$icon.'" onclick="showPopup('.$id.',\''.addslashes($pagetitle).'\',event);return false;" oncontextmenu="this.onclick(event);return false;" onmouseover="setCNS(this, 1)" onmouseout="setCNS(this, 0)" onmousedown="itemToChange='.$id.'; selectedObjectName=\''.addslashes($pagetitle).'\'; selectedObjectDeleted='.$deleted.';" /> ';
                                $output .= '<span p="'.$parent.'" onclick="treeAction('.$id.', \''.addslashes($pagetitle).'\'); setSelected(this);" onmouseover="setHoverClass(this, 1);" onmouseout="setHoverClass(this, 0);" class="treeNode" onmousedown="itemToChange='.$id.'; selectedObjectName=\''.addslashes($pagetitle).'\'; selectedObjectDeleted='.$deleted.';" oncontextmenu="document.getElementById(\'p'.$id.'\').onclick(event);return false;" title="'.addslashes($alt).'">'.$pagetitleDisplay.$weblinkDisplay.'</span> '.$pageIdDisplay.'</div>';
                            }
                            else {
                                // expandAll: two type for partial expansion
                                if ($expandAll ==1 || ($expandAll == 2 && in_array($id, $opened)))
                                {
                                    if ($expandAll == 1) {
                                       array_push($opened2, $id);
                                    }
                                    $output .= '<div id="node'.$id.'" p="'.$parent.'" style="white-space: nowrap;">'.$spacer.'<img id="s'.$id.'" align="absmiddle" style="cursor: pointer" src="'.$_style["tree_minusnode"].'" onclick="toggleNode(this,'.($indent+1).','.$id.',0,'. (($privateweb == 1 || $privatemgr == 1) ? '1' : '0') .'); return false;" oncontextmenu="this.onclick(event); return false;" /> <img id="f'.$id.'" align="absmiddle" title="'.$_lang['click_to_context'].'" style="cursor: pointer" src="'.(($privateweb == 1 || $privatemgr == 1) ? $_style["tree_folderopen_secure"] : $_style["tree_folderopen"]).'" onclick="showPopup('.$id.',\''.addslashes($pagetitle).'\',event);return false;" oncontextmenu="this.onclick(event);return false;" onmouseover="setCNS(this, 1)" onmouseout="setCNS(this, 0)" onmousedown="itemToChange='.$id.'; selectedObjectName=\''.addslashes($pagetitle).'\'; selectedObjectDeleted='.$deleted.';" /> ';
                                    $output .= '<span onclick="treeAction('.$id.', \''.addslashes($pagetitle).'\'); setSelected(this);" onmouseover="setHoverClass(this, 1);" onmouseout="setHoverClass(this, 0);" class="treeNode" onmousedown="itemToChange='.$id.'; selectedObjectName=\''.addslashes($pagetitle).'\'; selectedObjectDeleted='.$deleted.';" oncontextmenu="document.getElementById(\'f'.$id.'\').onclick(event);return false;" title="'.addslashes($alt).'">'.$pagetitleDisplay.$weblinkDisplay.'</span> '.$pageIdDisplay.'<div style="display:block">';
                                    makeHTML($indent+1,$id,$expandAll,$theme);
                                    $output .= '</div></div>';
                                }
                                else {
                                    $output .= '<div id="node'.$id.'" p="'.$parent.'" style="white-space: nowrap;">'.$spacer.'<img id="s'.$id.'" align="absmiddle" style="cursor: pointer" src="'.$_style["tree_plusnode"].'" onclick="toggleNode(this,'.($indent+1).','.$id.',0,'. (($privateweb == 1 || $privatemgr == 1) ? '1' : '0') .'); return false;" oncontextmenu="this.onclick(event); return false;" /> <img id="f'.$id.'" title="'.$_lang['click_to_context'].'" align="absmiddle" style="cursor: pointer" src="'.(($privateweb == 1 || $privatemgr == 1) ? $_style["tree_folder_secure"] : $_style["tree_folder"]).'" onclick="showPopup('.$id.',\''.addslashes($pagetitle).'\',event);return false;" oncontextmenu="this.onclick(event);return false;" onmouseover="setCNS(this, 1)" onmouseout="setCNS(this, 0)" onmousedown="itemToChange='.$id.'; selectedObjectName=\''.addslashes($pagetitle).'\'; selectedObjectDeleted='.$deleted.';" /> ';
                                   	$output .= '<span onclick="treeAction('.$id.', \''.addslashes($pagetitle).'\'); setSelected(this);" onmouseover="setHoverClass(this, 1);" onmouseout="setHoverClass(this, 0);" class="treeNode" onmousedown="itemToChange='.$id.'; selectedObjectName=\''.addslashes($pagetitle).'\'; selectedObjectDeleted='.$deleted.';" oncontextmenu="document.getElementById(\'f'.$id.'\').onclick(event);return false;" title="'.addslashes($alt).'">'.$pagetitleDisplay.$weblinkDisplay.'</span> '.$pageIdDisplay.'<div style="display:none"></div></div>';
                                    array_push($closed2, $id);
                                }
                            }
                            // store vars in Javascript
                            if ($expandAll == 1) {
                                echo '<script type="text/javascript"> ';
                                foreach ($opened2 as $item) {
                                         printf("parent.openedArray[%d] = 1; ", $item);
                                }
                                echo '</script> ';
                            } elseif ($expandAll == 0) {
                                echo '<script type="text/javascript"> ';
                                foreach ($closed2 as $item) {
                                         printf("parent.openedArray[%d] = 0; ", $item);
                                }
                                echo '</script> ';
                            }
                        }
                    }
                ?>
                  • 8522
                  • 145 Posts
                  And here is the file. Did somebody already open a feature request on jira?
                    • 8522
                    • 145 Posts
                    I added a patch as minor improvement to jira http://svn.modxcms.com/jira/browse/MODX-1405
                      • 3749
                      • 24,544 Posts
                      Thanks for the contribution. smiley
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting