New ALERT when page created

A client of mine has asked can I create a pop alert on the homepage when a new page is created and set as live in the back-end.

Anyone come across anything like this before on Modx Revo?

I have created the popup html code but wondering how to link it to only show when a new page is created.

Could use getResources/pdoResources with a limit of 1 and a sort of publishedon and order DESC. That’ll give you the last published resource, and you can use the other snippet properties to filter it further if needed (eg only in a certain section, resources shown in menu, etc).

Could I do the same to get the parent url instead of the child url? Let’s say I created two new news pages and the popup on my homepage would be. There are new News Articles and when you press on the button, it’d bring you to the News page and not the article page.

Home
About Us
News
— News 1
— News 2 (new)
— News 3 (new)
Contact Us

How would the publishedon work?

You could for example use the extra getDate. Set the &offset property to the timespan you consider a newly published page to still be “new”. Then use this value in the &where property of pdoResources.

[[!pdoResources?
    ...
    &where=`{"publishedon:>":[[!getDate? &offset=`-1 day`]]}`
]]

This should only return resources that were published in the last 24 hours.


Yes. You could use [[~[[+parent]]]] in the &tpl chunk.

2 Likes

Thanks a million. This worked a treat.