I recently learned about the great power of content rules.
This is extremely useful to me since it allows me to be notified when contributors upload their content to my website and ask for my review.
However it would be even more efficient if after my change of status to "public" a News item is generated with some basic content like just a title: "a new %item_type% %item_title% has been published".
At the moment i have to do it manually. I use this news to both advertise the availability of new content in my homepage and to feed collections that I use in my newsletter.
You could do this via an event-listener ("item published") in one of your custom add-ons with a Python-script.
Or with a script added to a transition's workflow-guard.
Or via a content-rule assigned to the portal or to a specific folder, with these settings:
- Event trigger: Workflow state changed
- Condition: Workflow transitions are: publish
- Action: Copy to folder "Recently published news"
However, it seems a little overkill to create news-items for just saying "has been published", I'd rather set the effective-date of an item to the current date when it's published, then create a collection and set its criteria to show news-items sorted by effective-date and set title to "Recently published news".
To do that, you'd need a Python-script-event-listener or workflow-guard again, or search for add-ons which extend the options of content-rules. There might be one offering this feature already.
Finally, I've read somewhere workflow-guards are not recommended, I assume that's due to the implicitness of guards, so better declare a component – the event-listener – in an add-on's zcml-file, that way it's always easily deductable where the magic is coming from.
I feel there is a smarter way then to add content for your use case.
Why can't you just make a (browser) view or collection that shows 'whats new'
There is an apparently little known view called recently_modified that shows new/changed items in reverse chronological order. I often use it at the root of a site.
Thanks very much.
I was definitely overthinking about the problem.
Probably it remains a useful discussion topic (create content with content rules), but there are simpler ways to address my problems
rapido allows for scriptable content rules. If you really want to create new content based on events thats probably your fastest way. A builtin content rule action to create new content is maybe a good idea but I'm not sure it would be used much.