We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8168
    • 1,118 Posts
    Hi guys,

    I am using getPage / getResources to create an index news page section in my site. This pulls the articles from a folder and on this index page uses a TPL to render them in a short list - this list includes the PUBLISHEDON tag - however when I view the index page - the PUBLISHEDON tag is not rendering the actual Published ON date??? Its showing the date the article was created... I have manually set these published dates to be in the past (as I am collecting past articles into the new site), but still only get the date that I created the article???

    Any ideas?

    Code as below:

    Main snippet call:

    [[!getPage?
       &elementClass=`modSnippet`
       &element=`getResources`
     
       &parents=`30`
       &depth=`2`
       &limit=`10`
       &pageVarKey=`page`
     
       &includeTVs=`1` &processTVs=`1` &includeContent=`1` &showHidden=`1`
    
     
       &tpl=`NewsAndEvents_IndexTpl`
    ]]


    Template Chunk:

    <!-- NEWS ITEM -->
    <div class="newsItemWrapper">
    <div class="newsItemLHS"><h5>[[*publishedon:strtotime:date=`%d/%m/%y`]]</h5></div>
    <h2><a href="[[~[[+id]]]]" target="_self" title="Read more about [[*pagetitle]]">[[+pagetitle]]</a></h2>
    <div class="newsItemMID">
    <p>[[+introtext]]</p>
    </div>
    <div class="newsItemRHS"><a href="[[~[[+id]]]]" target="_self" title="Read more about [[*pagetitle]]" class="moreButton">More...</a></div>
    <div class="hr"><hr/></div>
    </div>
    <!-- end of NEWS ITEM -->
      • 4172
      • 5,888 Posts
      you need to use the placeholder-tags, not the TV/Resource-field-tags:

      [[+publishedon:strtotime:date=`%d/%m/%y`]]


      The placeholder-tags are replaced by the values of the resource listed by getResources.

      The TV/Resource-field-tags are replaced by the the values of the Resource which you actually have requested.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 8168
        • 1,118 Posts
        Fab // thanks Bruno! ;]
          • 36516
          • 179 Posts
          Born from sheer inexperience I had a problem today (v2.4.2) with getResources and showing the publish date. It seems [[*publishedon]] used on the article page itself produces a date string, while the [[+publishedon]] placeholder generated by getResources produces a unix timestamp. The apparent difference being that getResources is using strtotime before setting the placeholder.

          The most obvious issue I've experienced is that on my page template I used:

          [[*publishedon:strtotime:date=`%d/%m/%y`]]

          But in my article summary chunk for the main blog page I had to shorten it to:

          [[+publishedon:date=`%d/%m/%y`]]

          ...dropping ":strtotime" because it was no longer necessary. All good for efficiency I suppose, but I had to spend quite a bit of time trying to work out what was going on. Is this a known discrepancy or am I just misunderstanding something?