We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36551
    • 416 Posts
    I've recently started adding a small custom dashboard for my client sites that simply display system settings for the Site name, login name and the version of Modx installed.

    It would be cool if there was a way to show that there is a new version available or the current version number.
      • 3749
      • 24,544 Posts
      The version number of the version you're running is available with this:

      [[++settings_version]]


      You could get the latest version number from http://modx.com/download/ with cURL, but there's probably an easier way.
        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
        • 36551
        • 416 Posts
        Yep, I'm using the system setting for the installed version.

        I was just hoping someone had figured out how to notify the site admin that an upgrade is available.

        Still hoping for the one-click upgrade. . . smiley
        • The news feed notifies of new releases.
            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
            • 36551
            • 416 Posts
            Yes it does! Thanks for the reminder.
            • I do pay attention and keep this updated, although it's easy enough to update the code if necessary https://github.com/sottwell/installer
                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
              • This is actually a feature that should be part of the core. We'd have to build or alter the current extras API in order to create a response and then a notice feature in the UI. It's something I would like to see in 2.4.
                  Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. BlogTwitterLinkedInGitHub
                  • 23018
                  • 353 Posts
                  I played around with the git api and found a way to retrieve a complete list of all available zipballs from the latest one down to v2.2.0-pl2:

                  curl -i https://api.github.com/repos/modxcms/revolution/tags


                  @sottwell I've downloaded the latest zipball and it is NOT identical to the pl installation package sad

                  The tags seem to be sorted in a way that we can use to extract the latest version.

                  [
                    {
                      "name": "v2.3.3-pl",
                      "zipball_url": "https://api.github.com/repos/modxcms/revolution/zipball/v2.3.3-pl",
                      "tarball_url": "https://api.github.com/repos/modxcms/revolution/tarball/v2.3.3-pl",
                      "commit": {
                        "sha": "b754e6e619837bd41c7c4e2ba6ecacb67e6732a4",
                        "url": "https://api.github.com/repos/modxcms/revolution/commits/b754e6e619837bd41c7c4e2ba6ecacb67e6732a4"
                      }
                    },
                  ...
                  ]
                  


                  Comparing it against the system setting should tell us what we want to know:

                  <?php
                  $url = "https://api.github.com/repos/modxcms/revolution/tags";
                  
                  $user_agent = 'revolution';
                  
                  function get_content_from_github($url,$user_agent) {
                  	$ch = curl_init();
                  	curl_setopt($ch,CURLOPT_URL,$url);
                  	curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
                  	curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1);
                  	curl_setopt($ch,CURLOPT_USERAGENT,$user_agent);
                  	$content = curl_exec($ch);
                  	curl_close($ch);
                  	return $content;
                  }
                  
                  $tags = get_content_from_github($url,$user_agent);
                  
                  $tags = json_decode($tags);
                  
                  $latest = get_object_vars($tags[0]);
                  
                  $latest = trim ($latest['name'], 'v.'); //v2.3.3-pl.
                  
                  $version = $modx->getOption('settings_version'); //2.3.3-pl
                  
                  if($latest == $version){
                      return "Your MODX setup is up-to-date ($version)";
                  }
                  else{
                      return "You should update from ".$version." to ".$latest;
                  }


                  Don't know how clever it is to rely on the sort order of the tags json, but it seems to do the job.

                  Cheers,

                  pepebe [ed. note: pepebe last edited this post 9 years, 1 month ago.]
                    Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
                  • I believe that the official MODX releases are streamed from an Amazon repository, so they probably wouldn't be the same as the ones from git.

                    In fact, I'm told that the zips from github are source, not built.
                      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
                      • 23018
                      • 353 Posts
                      Quote from: sottwell at Mar 03, 2015, 03:43 PM
                      I believe that the official MODX releases are streamed from an Amazon repository, so they probably wouldn't be the same as the ones from git.

                      In fact, I'm told that the zips from github are source, not built.

                      This is correct, but as I remember, all it takes is to rename a few files in _build/ and then run _build/transport.core.php to create a traditional (or advanced?) modx package.

                      I don't know the dirty details, but I guess it should be possible to build a nice update dashboard on top of this.
                        Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe