Notifications Drop-down

On my website I have a notification icon in the top right hand corner.

I’m using a GetResources to retrieve new pages. So when I create a new page, a new notification comes into the drop-down…New Page Available Here!

[[getResources:default=`<h5 >Currently no new material available</h5>`? 
  &where=`{"publishedon:>":[[!getDate? &offset=`-14 day`]]}`

It works a treat. I have it set to WHERE PUBLISHEDON = OFFSET -14 DAYS.

My question is this - Is it possible for the GetResources to also retrieve pages that have been edited? So a pages that already exists but the content has been edited.

Yes, use editedon instead of publishedon.

Or, if you want to combine them so it shows anything published OR edited in the last 14 days:

  &where=`{"publishedon:>":[[!getDate? &offset=`-14 day`]], "OR:editedon:>":[[!getDate? &offset=`-14 day`]]}`
1 Like

Ahhhhh Mark…thanks a million. That works a treat :slight_smile:

Can I pick your brain again. In the Notification Dropdown, I’m showing the page that has been published or edited now. Directly under the page I’m showing the date. I had the published date there. Is there a way that I could show the published date if new or edited date if page is edited? Which every date is newer.

You probably have to write a custom snippet for this.
Something like this may work:

$published_timestamp = strtotime($publishedon);
$edited_timestamp = strtotime($editedon);
$format = "%d.%m.%Y %H:%M";
if ($published_timestamp > $edited_timestamp){
    return strftime($format, $published_timestamp);
} else {
    return strftime($format, $edited_timestamp);

Snippet call (in chunk “notificationNUA”):

[[getNewerDate? &publishedon=`[[+publishedon]]` &editedon=`[[+editedon]]`]]

Could also just used the editedon date all the time. Manually publishing a resource should update that, too.

(Note strftime is deprecated and scheduled to be removed in PHP 9)

1 Like

Thanks again Mark. I appreciate the help