We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 696
    • 46 Posts
    As Google and other searchengines penalise you if all your pages are generating saying they where created 0seconds ago IE current time which with Mod_Rewrite they are in a sence i have been looking at alternatives one being a simple Meta Tag that you can add to your head containing the last Edit / Creation date of the document in question, this helps Google reindex the pages that have changed and leave those that havent with current data.

    So its a Simple Question, How do i call the Creation Date And Last Edit Date From the database, i know i can do it through a simple Db connect ect, but im just wondering if there is a function in Modx already to just call these just as you can call the current Alias and Child Aliases Ect...

    All help would be great...

    Thank you all...

    -----------------------

    Appolagies to all if that didn’t make sense its now 1:30 am on wednesday and the last time i slept was 9:50 am Monday...

    Thanks Again All
      • 18397
      • 3,250 Posts
      $modx->documentObject["createdon"]; for the current document.
      • That and $modx->documentObject[’editedon’] will provide UNIX timestamps; you would need to put this meta tag directly in your template and use a snippet and filter this value through the strftime() function. The snippet should return a date in the format "Sun, 06 Nov 2005 08:49:37 GMT+2". Modify the GMT + or - as appropriate for your time zone.
          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
          • 4095
          • 372 Posts
          Why don’t you just use last-modified. I use this on my homepage:

          <meta http-equiv="last-modified" content="Wed, 08 Mar 2006 12:08:09 +1300" />
            [img]http://www.emanz.ac.nz/assets/images/logo/emanz-icon_16x16.gif[/img] Emergency Management Academy of New Zealand [br] http://www.emanz.ac.nz[br][br]MODx Sandbox Login: sandbox Password: castle [br]
            Admin Sandbox Login: sandbox Password: castle
          • But for every document? Every time you edit one of your documents? For that, you need to use a snippet that generates the appropriate date/time:

            <meta http-equiv="last-modified" content="[[lastmodified]] +1300" />


            goes in the template, and the lastmodified snippet would use the above code to generate the correct date for every page. It would get cached, but the cache is cleared any time you edit a document, so that’s not going to cause any problems.
              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
              • 4095
              • 372 Posts
              Quote from: sottwell at Mar 15, 2006, 11:07 AM

              But for every document? Every time you edit one of your documents? For that, you need to use a snippet that generates the appropriate date/time:

              Sorry, I wasn’t very clear. That was an output from my template to demonstrate the result. I use MetaTagsExtra to generate the output as it has many other functions I use aswell, I just disabled keywords from memory.

              The relevant code is as follows:

              // *** LAST MODIFIED ***
              $editedon = date(r,$docInfo['editedon']);
              $MetaEditedOn = " <meta http-equiv=\"last-modified\" content=\"$editedon\" />\n";
              
              // *** RETURN RESULTS ***
              return $MetaEditedOn;
              


                [img]http://www.emanz.ac.nz/assets/images/logo/emanz-icon_16x16.gif[/img] Emergency Management Academy of New Zealand [br] http://www.emanz.ac.nz[br][br]MODx Sandbox Login: sandbox Password: castle [br]
                Admin Sandbox Login: sandbox Password: castle
                • 4095
                • 372 Posts
                Quote from: Briggsy at Mar 15, 2006, 01:07 PM

                Sorry, I wasn’t very clear. That was an output from my template to demonstrate the result. I use MetaTagsExtra to generate the output as it has many other functions I use aswell, I just disabled keywords from memory.

                Snippet canbe found at http://modxcms.com/forums/index.php/topic,3425.msg24472.html#msg24472
                  [img]http://www.emanz.ac.nz/assets/images/logo/emanz-icon_16x16.gif[/img] Emergency Management Academy of New Zealand [br] http://www.emanz.ac.nz[br][br]MODx Sandbox Login: sandbox Password: castle [br]
                  Admin Sandbox Login: sandbox Password: castle