We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10449
    • 956 Posts
    This is an auto-generated support/comment thread for lastUpdate.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    displays the last edited document
      • 29076
      • 615 Posts
      Thanks for a great snippet. I use it on my site. Is there a way to show the 5 last updated documents?
        I think, thererfor I am! But what I am, and why...?
        • 10449
        • 956 Posts
        <?php
        $dbQuery = "SELECT id, pagetitle, FROM_UNIXTIME(editedon, '%d.%m.%Y [%H%:%i:%s]') AS humanDate FROM modx_site_content ORDER BY editedon DESC LIMIT 0,5";
        $result = mysql_query($dbQuery) or die( mysql_error() );
        
        if(mysql_num_rows($result) > 0) {
        echo "<b>Our 5 most recent articles: </b><br />";
        	while ($row = mysql_fetch_array($result)) {
        		extract($row);
        		$url = $modx->makeUrl($id, '', '', 'full');
        		echo "<a href=\"$url\">$pagetitle</a> - $humanDate <br />";
        	}
        }
        ?>
        



        I know I know... using markup in a snippet is considered a bad habit... but this should do the trick.
          • 29076
          • 615 Posts
          (I will not tell anyone wink )

          Thanks, it works perfect.
            I think, thererfor I am! But what I am, and why...?
            • 13137
            • 204 Posts
            Does any body know if it would be possible to exclude certain documents or IDs from being displayed?
            Such as private pages, forms, xml, etc.
              • 10449
              • 956 Posts
              Not sure about forms, since they’re just regular html, but here’s a variety of the above query:

              SELECT id, pagetitle, FROM_UNIXTIME(editedon, '%d.%m.%Y [%H%:%i:%s]') AS humanDate 
              FROM modx_site_content 
              WHERE contentType='text/html' AND
              published=1 AND
              deleted=0 AND
              hidemenu=0 AND
              privateweb=0
              ORDER BY editedon DESC LIMIT 0,5
              


                • 13137
                • 204 Posts
                Thanks for your info.
                I think that "hidemenu" should cover about 90% of my needs.
                If you know of a way to exclude an ID, that would cover the last 10% wink
                  • 10449
                  • 956 Posts
                  it’s just regular sql...


                  
                  SELECT id, pagetitle, FROM_UNIXTIME(editedon, '%d.%m.%Y [%H%:%i:%s]') AS humanDate 
                  FROM modx_site_content 
                  WHERE contentType='text/html' AND
                  published=1 AND
                  deleted=0 AND
                  hidemenu=0 AND
                  privateweb=0 AND
                  id NOT IN(34,55,99,120)
                  ORDER BY editedon DESC LIMIT 0,5
                  
                  
                    • 13137
                    • 204 Posts
                    grin Super-duper, Thanks
                      • 12147
                      • 182 Posts
                      Sorry for my ignorance... I am getting this from lastUpdate install:

                      "Last update: MODx CMS Install Success - 25.10.2005 [22:35:27]"

                      What I want is:
                      "Last update: Month Date, Year" [that’s all I need! This would display on all pages, and just indicate when the last update on any page was made/when the site was last updated)

                      Could anyone help me with this?

                      Thank you!
                      Wendy