I’m using this code to fetch intro’s to News items including it’s
publishedon datefield. It does get the dates for the first three but not for the subsequent ajax requests.
&ajaxTplMore=`@INLINE <button class="actionButton btn-more">Meer laden</button>`
All items fetched beyond the limit set show a date of 1/1/1970
If I change the limit to 6, the first six are correct.
Is this a bug or can I set some parameter to fix this?
In your template chunk “item_nieuws”, how do you output the value of the
publishedon field? Do you use an output modifier?
Yes, I do:
[[!+publishedon:hideYearWithinThisYear]] which strips the year if it is less than a year ago.
Because you’re asking, I tried
[[!+publishedon:date=%e %B %Y
]] too, and it returns empty, which explains the 1/1/1970.
hideYearWithinThisYear snippet is as following:
$myDate = intval($input, 10);
$longFormatString = '%e %B %Y';
$shortFormatString = '%e %B';
$now = time();
$year = 31536000; // 365 * 24 * 60 * 60
$yearAgo = $now - $year;
$formatString = $myDate > $yearAgo ? $shortFormatString : $longFormatString;
$result = strftime($formatString, $myDate);
It works correctly if the placeholder is cached
If the placeholder is uncached (
[[!+publishedon:hideYearWithinThisYear]] however, then the output modifier somehow doesn’t get an input value.
But I don’t know why exactly.
It works correctly, if the data isn’t loaded with AJAX.
Maybe try using this syntax, if the snippet has to be uncached:
Just calling it uncached did it!
It’s a bit unclear to me when to use uncached. Maybe I should try that only if cached doesn’t work.
This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.