We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4095
    • 372 Posts
    I’m trying to get the date to show up in the archived items as well and have tracked it down to the following section. However when I insert [+date+] nothing happens. However if I add text after [’pagetitle’] it is shown.

    What am I doing wrong?

    if($limit>$nrposts && $showarch === true) { 
       $output .= "<h3>$archtxt</h3>";
       $output .= "<ul class=\"archivelist\">";
       for ($x = $nrposts; $x < $limit; $x++) { 
          $output .= "<li><a href='[~".$resource[$x]['id']."~]'>".$resource[$x]['pagetitle']."</a></li>";
       } 
       $output .= "</ul>";
    }

      [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
    • The [+date+] placeholder is part of the output template, and the archive list is displayed after the template. I would suggest adding the strftime($date, $resource[$x][’createdon’] to the output line in the code you quoted below, like this:

            $output .= "<li><a href='[~".$resource[$x]['id']."~]'>".$resource[$x]['pagetitle']."</a>".strftime($date, $resource[$x]['createdon']."</li>";
        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
        If I try that it displays the following after the link:

        .strftime(%d-%b-%y, %H:%M, Array[’createdon’].

        I tried doing things like that earlier (trail and error) but got similar errors. I guess I’m doing soemthing wrong and I don’t really understand PHP yet.
          [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
        • That always gets my blood pressure up! It’s because the code has to be outside of the string. In the line of code I quoted below,

                
          $output .= "<li><a href='[~".$resource[$x]['id']."~]'>" .$resource[$x]['pagetitle']. "</a>" .strftime($date, $resource[$x]['createdon']. "</li>";


          notice the placement of the " and the .

          I’m sure you’ve learned that PHP uses the . for the concat operator (adding a string to another string) instead of + like just about everything else. That took me a long time to get used to.

          So basically what you are doing is taking a string (in quotes) then generating another string with PHP code (not in the quotes), and combining the two strings. I rarely get it right the first (or first two or three!) time; I’m sort of a trial-and-error hacker. A good color-coded text editor helps a lot!
            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
            Thanks Susan, but still having problems.

            " .strftime($date, $resource[$x]['createdon']. "


            I don’t think the problem was in the placement of the . and " since the rest of the code shows no spacing as per your original post. However it is that piece of code, if I remove it, everythin returns to normal with no date or error

            Seems I must have done something a little different before, cos now I get the following error no matter which of the two ways I do it, and I can’t get the previous error anymore.

            Parse error: parse error, unexpected ’;’ in /home/site/public_html/manager/includes/document.parser.class.inc.php(667) : eval()’d code on line 313

            Removing the ; only tells me something else is wrong till I have totally destroyed the code smiley

            Maybe Mark or Ryan can shed light on how to make the archived items show a date on the line next to the title?
              [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