We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10525
    • 247 Posts
    I just upgraded a site to 2.3.5. I haven't done much with it yet, but it appears to have installed ok. However, I am pretty disappointed to see that still nothing has beeen done to address the calls for the site name and modx version to be reinstated in the header. There have been many requests for this, in several posts.

    I need to know which site's manager I am in. I also need to be able to see quickly if a site needs updated. Too much of the discussion about this functional requirement has been stymied by discussion about style - where it should go and how it should look. This is pretty frustrating. (Who postpones buying a car for years because they can't find the right shade of purple?....)

    Anyway, if anyone else wants a quick and dirty way to stick this info in the managers' headers, here's one:

    1. Open \manager\templates\default\header.tpl

    2. Find this code block and add the lines I have named "#modx-header-info-hack":

    <div id="modx-navbar">
    
    	<ul id="modx-user-menu">
    		{* eval is used here to support nested variables *}
    		{eval var=$userNav}
    	</ul>
    
    	<ul id="modx-topnav">
    		<li id="modx-home-dashboard">
    			<a href="?" title="{$_lang.dashboard}">{$_lang.dashboard}</a>
    		</li>
    		{if $_search}
    			<li id="modx-manager-search"></li>
    		{/if}
    		{$navb}
    	</ul>
    
    	<ul id="modx-header-info-hack" style="float:left;">
    		<div style="height:55px; line-height:55px; margin-left:10px;">
    			<span style="display:inline-block; vertical-align:middle; line-height:normal;">
    				Your Site Name<br/>
    				modx: 2.3.5-pl
    			</span>
    		</div>
    	</ul>
    
    </div>
    

    This is obviously all manually hard-coded. You'll need to re-insert the code block and update the version whenever you upgrade. This displays fairly discreetly in black on the header, but you can style as you wish.

    Sits just to the right of the main menu. Just move #modx-header-info-hack above #modx-user-menu to have it positioned first on the header bar.

    If anyone knows any quick and easy ways to pull these two values (site name and modx version) into the template from the database, or even from \core\cache\system_settings\config.cache.php (which is generally present), that would be a great help. I tried a few methods but got nowhere.

    This question has been answered by Gav. See the first response.

      • 42562
      • 1,145 Posts
      Thanks for showing where exactly to put this version number.

      I too think it is vastly important to see this version number immediately. Beats me, why it was left out, since it is only the most important thing.
      In 2.3.5, I honestly have to remember (not successfully at all times, in fact it can take me up to 3 minutes searching) that the info is couched three mouse actions deep:
      Hover over Manage > Reports > System Info

      Since this is absolutely ridiculous when accessing multiple instances of MODx, I paste this line of code MODx.config.version in my Chrome's console command line.

      Or following your idea above, in header.tpl toss this just before the head tag (HTML tags are generated automatically)
      <script>//your new code
      Ext.onReady(function() {
      var topNav = document.getElementById("modx-topnav");
         topNav.insertAdjacentHTML( "afterEnd", "<ul id=\'versionCheck\'><li><a href=\'http://modx.com/download/\' target=\'_blank\' title=\'This is the version of this instance of MODx. Click to check MODx.com for newer versions\'>MODx "+MODx.config.version+"</a></li></ul>");
       });
      </script>
      
      </head>//insert new code just before head tag

      or right after new MODx.SearchBar;
      <script type="text/javascript">
          Ext.onReady(function() {
              new MODx.SearchBar; // find this
      //new code starts
              var topNav = document.getElementById("modx-topnav");
              topNav.insertAdjacentHTML( "afterEnd", "<ul id=\'versionCheck\'><li><a href=\'http://modx.com/download/\' target=\'_blank\' title=\'This is the version of this instance of MODx. Click to check MODx.com for newer versions\'>MODx "+MODx.config.version+"</a></li></ul>");
      //new code ends
       });
      </script>

      or instead of meddling with header tpl for all your sites
      Create a plugin, say versionDisplay, fire it at system events OnBeforeManagerPageInit
      $versionCheck = '
       Ext.onReady(function() {
         var topNav = document.getElementById("modx-topnav");
         topNav.insertAdjacentHTML( "afterEnd", "<ul id=\'versionCheck\'><li><a href=\'http://modx.com/download/\' target=\'_blank\' title=\'This is the version of this instance of MODx. Click to check MODx.com for newer versions\'>MODx "+MODx.config.version+"</a></li></ul>");
       });
      ';
      $modx->regClientStartupHTMLBlock("<script>" . $versionCheck . "</script>");
        TinymceWrapper: Complete back/frontend content solution.
        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
      • Or just install the Updater dashboard widget extra and be done with it.
          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
          • 42562
          • 1,145 Posts
          Ah yes, that Extra does the work too.

          To add Site name, replace
          ...versions\'>MODx "+MODx.config.version+"</a></li></ul>

          With
          ...versions\'>"+MODx.config.site_name+": "+MODx.config.version+"</a></li></ul>
          //if the display is too long, use CSS to kill it

          Or you can place the Site Name in the title attribute
          title=\'Site Name: "+MODx.config.site_name+"\'>"Revo": "+MODx.config.version+"</a></li></ul>
            TinymceWrapper: Complete back/frontend content solution.
            Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
            5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
            • 10525
            • 247 Posts
            Thankyou very much for that donshakespeare, these suggestions are great. And I'm with you on always forgetting where to find the buried version no.

            There's a lot of stuff I'm unfamiliar with here, particularly the means of picking up system values via javascript (ie MODx.config.version). And I like the link to check the latest version too. Very useful.

            Do you know if it's possible to pick up the site name also by this means? Is there a list of such variables in the docs or elsewhere? (I tried googling "MODx.config.version" with no luck).

            Thanks again.

            edit: ah! you just beat me with the answer before my question! smiley


            And thanks for the Updater info Susan. Also looks v useful. [ed. note: Gav last edited this post 8 years, 9 months ago.]
              • 42562
              • 1,145 Posts
              Glad to help.
              If not for Chrome's autocomplete in dev tools, I would never have known about these variables.
              I stopped wasting time looking for where they are all listed.
              In fact all (I believe) the variables/values in your System Settings are exposed, don't know how, but they are.

              While in Manager, using Chrome > inspect elements>Console
              ...start typing in command line

              MODx. (autocomplete will suggest this or that)
              MODx.config. (autocomplete will suggest a gazillion options)

              This is where I insert a stage direction:
              [[Open jaw here, leave dropped for a minute until exit]]
                TinymceWrapper: Complete back/frontend content solution.
                Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
                • 10525
                • 247 Posts
                Geez, you're right, where did these all come from?

                I find it extremely difficult to learn new stuff about modx these days. The doc are next to useless for me: a huge mix of stuff covering multiple modx versions, different authors, different styles, different levels of depth and accuracy. Many pages just stop dead wwith no indication of where to go next.

                Right now I cannot find a clear illustration of how to create a simple plugin to run the code you suggested, just a lot of abstract stuff about what plugins ARE. There is a tut page, on Extras. If this is the same as a Plugin, a much simpler example would be useful, as well as an explanation of the different terms.

                I wish they could just fork the entire docs collection for each version, then you would only have to read stuff pertaining to one version.

                As for the auto-generated API docs, they are also near-useless. I liked Java docs way back. Even a complete novice like me then found them clear, predicatble and easy to navigate through.
                  • 42562
                  • 1,145 Posts
                  Auto-generated docs are not for humans - my opinion!
                  Yup, some stale tuts out there, tech moves rather fast though.
                  MODx tries to make things intuitive, but aren't we all different.

                  OPEN TWO MANAGER INSTANCES in your browser tabs
                  Leave one untouched and open until you successfully run this plugin and nothing bad happens, and you have given feedback on this forum


                  Go to resource tree >Elements Tab
                  Find Plugins 4th bar down (click the plus sign) or click the gears to create a new plugin right at the top beneath the Element Tab

                  Or straight link site.com/manager/?a=element/plugin/create&category=0

                  Three tabs on that page
                  1st Tab create/edit plugin
                  Enter plugin name versionDisplay

                  In Plugin code (php):
                  <?php //delete this if you like

                  paste
                  $versionCheck = '
                   Ext.onReady(function() {
                     var topNav = document.getElementById("modx-topnav");
                     topNav.insertAdjacentHTML( "afterEnd", "<ul id=\'versionCheck\'><li><a href=\'http://modx.com/download/\' target=\'_blank\' title=\'This is the version of this instance of MODx. Click to check MODx.com for newer versions\'>MODx "+MODx.config.version+"</a></li></ul>");
                   });
                  ';
                  $modx->regClientStartupHTMLBlock("<script>" . $versionCheck . "</script>");


                  2nd Tab system events
                  Ctrl + F look for OnBeforeManagerPageInit
                  Checkbox it

                  SAVE!

                  Now test it by navigating away, or by opening another Manager page
                    TinymceWrapper: Complete back/frontend content solution.
                    Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                    5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
                    • 42562
                    • 1,145 Posts
                    Because you are using OnBeforeManagerPageInit the plugin will run always on every page of the Manager.
                    Because you are dealing with PHP, if you make a mistake in one simple punctuation, the Manager will turn blank and freak the living day light out of you

                    Noli timere! there is a quick fix without reinstalling the internet.

                    That is why I asked to leave one Manager instance open, unrefreshed, untouched.

                    Go to Resource Tree > Plugins (refresh the tree - not the browser)
                    Find the new plugin, right-click
                    - quick update - delete the code or fix the issue
                    OR
                    - disable plugin

                    clean your cache
                      TinymceWrapper: Complete back/frontend content solution.
                      Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                      5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
                    • discuss.answer
                      • 10525
                      • 247 Posts
                      donshakespeare this is excellent - clear and concise, thankyou!

                      I am now battling an error message which pops up very briefly when I try to save the plugin. After about 20 attempts (based on old Space Invaders timing skills) I managed to screen-capture the error:

                      Unexpected token <:
                      Forbidden
                      You do not have permission to access this document.

                      Web server at mydomain.com
                      Given that the site is a duplicated dev site in a subdirectory (mydomain.com/dev20/), I'm guessing there's a path that hasn't been updated post-duplication or by the update to 2.3.5.

                      Now trying to hunt down the solution to this...