pdoPage doesn't fetch publishedon date in ajax requests beyond the limit set

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.

[[!pdoPage?
    &parents=`[[++site_news]]`
    &hideContainers=`1`
    &depth=`0`
    &limit=`3`
    &sortby=`menuindex` 
    &sortdir=`ASC` 
    &offset=`1`
    &prepareTVs=`1`
    &processTVs=`1`
    &includeTVs=`imageSrcSet,linkToPage,buttonText`
    &tpl=`item_nieuws`
    &ajaxTplMore=`@INLINE <button class="actionButton btn-more">Meer laden</button>`
    &ajaxMode=`scroll`
    &showUnpublished=`[[!isAuthenticated]]`
]]

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:

<?php
$myDate = intval($input, 10);

setlocale(LC_ALL,'nl_NL.UTF-8');
$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);

return $result;

It works correctly if the placeholder is cached [[+publishedon:hideYearWithinThisYear]].

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: [[!hideYearWithinThisYear? &input=`[[+publishedon]]`]]

1 Like

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”.