We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20231
    • 12 Posts
    Howdy! Trying to finish up my work on this jobs listings website, but having a problem displaying the date of a document on it’s individual page. I’ve got it working on both the homepage and the main job listings pages using the following chunks as templates of my Ditto call:
    <div class="hotjob [+tags+]">
    						<div class="job_date">[+createdon:date=`%b<strong>%d</strong>`+]
    						</div>
    						<h3 class="job_title"><a href="[~[+id+]~]">[+title+]</a></h3>
    						
    						[[tagLinks? &id=`[+id+]` &tv=`tags` &separator=`, ` &fap=`1` &path=`categories` &label=`Tags: ` &style=`job_tags`]]
    						
    						<div class="job_info">
    							<p>[+introtext+] [+link+]
    							 <a class="more_link" href="[~[+id+]~]">View this job</a>	
    							</p>
    							
    						</div>
    						<div class="cleared"></div>
    					</div>


    But, for each individual listing, the document uses the following page template:
    {{head}}
    
    <body id="job">
    	<div id="container">
    			
    		<div id="header_wrap">
    			<div id="header_phone">Call us today: <span></span></div>
    			<div id="header">
    				<h1><span>acme Jobs</span></h1>
    				{{navigation}}
    			</div>
    		</div>
    		<div id="content_wrap">
    			<div id="content">
    				<div class="job_post [*tags*]">
    					<div class="job_date">[*createdon:date=`%b<strong>%d</strong>`*]
    					</div>
    					<h3 class="job_title"><a href="[~[*id*]~]">[*pagetitle*]</a></h3>
    					
    					[[tagLinks? &id=`[*id*]` &tv=`tags` &separator=`, ` &fap=`1` &path=`categories` &label=`Tags: ` &style=`job_tags`]]
    					
    					<div class="job_info">
    						[*content*]
    					</div>
    					
    					<ul class="job_data">
    						<li>Salary: <span>[*salary*]</span></li>
    						<li>Benefits: <span>[*benefits*]</span></li>
    						<li>Location: <span>[*location*]</span></li>
    						<li>Qualifications: <span>[*qualifications*]</li>
    					</ul>
    					
    					<div class="cleared"></div>
    				</div>
    				
    			</div>
    		
    			{{sidebar_job}}
    		</div>
    		<div id="footer_wrap">
    			{{footer}}
    		</div>
    		
    	</div>
    </body>
    </html>


    And it doesn’t work. Just get a blank spot where the date should be. Why is the createdon tag not working in this context?
      • 20413
      • 2,877 Posts
      Try use &dateFormat=`%b<strong>%d</strong>` in the ditto call, and use [+date+] placeholder
      //I think createdon is default otherwise use &dateSource=`createdon`
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 20231
        • 12 Posts
        That doesn’t seem to work. I put that &dateFormat=`%b<strong>%d</strong>` in the ditto call (on the main Jobs page template), and then put the
        [+date+]
        placeholder in the appropriate place in my Listing template.

        Basically, the ditto call is on the Jobs template page, and then clicking a link on one of the results of that call takes you to that document, using another template. Could that be why it’s not working?
          • 20413
          • 2,877 Posts
          Yeah... I assumed you were using ditto &tpl=`dynamicChunk`
          Then Ditto would get the placeholders of for instance a tv [+tvName+]
          from that document/resource nomatter where you had the Ditto call.

          Show the Ditto call! Try use [[...]] brackets.

          http://ditto.modxcms.com/tutorials/creating-a-custom-template.html

          //If this is what you do I dont understand why it wouldn’t work... huh
            @hawproductions | http://mrhaw.com/

            Infograph: MODX Advanced Install in 7 steps:
            http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

            Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
            http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
            • 16278
            • 928 Posts
            When you are using your template chunk from a Ditto call with [+createdon:date=`%b<strong>%d</strong>`+], Ditto is formatting the date with the help of the PHx files it includes. When you show your actual document, you’re not using Ditto, and if you don’t have the PHx plugin installed, you don’t have PHx processing either.

            It’s probably not worth installing PHx as a plugin just for the sake of this. You just need a little snippet to translate the createdon timestamp into the format you want. There will be some better written ones knocking about, but here’s a rough and ready example:
            <?php
            // dateForm
            // display Unix timestamp as formatted date
            
            $dateFormat = (isset($dateFormat)) ? $dateFormat : '%d %b %Y';
            $output = strftime($dateFormat,$dateSource);
            
            return $output;
            ?>

            Snippet call:[!dateForm?dateSource=`[*createdon*]` &dateFormat=`%b<strong>%d</strong>` !]
            laugh KP
              • 20231
              • 12 Posts
              Ah, ok. I was wondering if it was something like that that had to do with the difference of displaying the date from a Ditto call and from a normal document.

              Your snippet worked beautifully, thanks! I’m indebted to you! laugh