We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20041
    • 83 Posts
    huh
    Used Ditto for Newslisting. When I click on the more.. link, that news is displayed in full.
    How to get the News Item Title and Date on that page.
    I used
    <div class="post_ttl">[+title+]</div>
    <div class="post_dat">[+date+]</div>
    But nothing is getting displayed there.
    Kindly tell me what I’m doing wrong here.
    Thank you for your time.
      • 1186
      • 202 Posts
      [+title+] and [+date+] are not MODx document variables, I think that’s why Ditto doesn’t display anything.
      Try [+pagetitle+] or [+longtitle+] instead of [+title+], and [+pub_date+] instead of [+date+], or whatever you need, there’s a description here of all document variables : http://modxcms.com/document-tvs.html, and according to my experience, it works fine with Ditto.

      Hope this will help you !
        R
        • 20041
        • 83 Posts
        Thanks a lot, that certainly helped.
          • 33337
          • 3,975 Posts
          modxusr, the PDF file in Ditto archive has complete reference to the tags used in Ditto!
            Zaigham R - MODX Professional | Skype | Email | Twitter

            Digging the interwebs for #MODX gems and bringing it to you. modx.link
            • 20041
            • 83 Posts
            I got the news title right. But,
            somehow the news publish-date is displaying as 01-01-1970
            I created a snippet with
            return strftime("%d-%m-%Y %H:%M:%S", $publ_date);
            and called it as [[PublDate]]
            Please tell me what I am missing here.

            Thanks a lot.
              • 7923
              • 4,213 Posts
              Look for an example at this snippet: http://modxcms.com/forums/index.php/topic,3588.msg34361.html#msg34361

              Please use search and read the docs.


                "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                • 20041
                • 83 Posts
                Thank you.
                But I had seen that post following the thread
                http://modxcms.com/forums/index.php/topic,4979.0.html
                I had tried the snippet with the following part
                return $createdon = date('d-M-y h:i:s A',$docInfo['createdon']);

                But got the same result as before.
                Confused..Let me try it again.
                  • 18397
                  • 3,250 Posts
                  Wait a minute, are you just trying to show the news title and date on the FULL news page (not the list).

                  If so, all you need to do is:

                  [*longtitle*] (or pagetitle)

                  And this for the date: http://modxcms.com/forums/index.php/topic,3588.msg34361.html#msg34361
                    • 20041
                    • 83 Posts
                    Yes , exactly..Thanks Mark.
                    Got the first part right already.
                    It’s the date part I’m after...
                    Tried that already...but it displays a blank huh
                    Any help appreciated. Thanks.
                      • 7923
                      • 4,213 Posts
                      Quote from: modxusr at Jun 27, 2006, 01:23 PM

                      I had tried the snippet with the following part
                      return $createdon = date('d-M-y h:i:s A',$docInfo['createdon']);

                      You are not creating the $docInfo variable in that snippet (what is used to get the date from). Try this:

                      // format for the Date
                      if(!isset($dateFormat)) {
                      	$dateFormat="%d-%b-%y %H:%M";
                      }
                      // Date field to use (ex: createon, editeon, pub_date, etc...)
                      if(!isset($usedDate)) {
                      	$usedDate='createdon';
                      }
                      // Document to get the date from
                      if(!isset($docId)) {
                      	$docId=$modx->documentIdentifier;
                      }
                      $docInfo = $modx->getDocument($docId);
                      
                      if ($modx->config['etomite_charset']=='UTF-8') {
                      	$createdon = utf8_encode(strftime($dateFormat, $docInfo[$usedDate]));
                      } else {
                      	$createdon =  strftime($dateFormat, $docInfo[$usedDate]);
                      }
                      return $createdon;


                        "He can have a lollipop any time he wants to. That's what it means to be a programmer."