Plone content rules: how to manage your content in a flexible way

Brief introduction on Plone 'content rules'. We will see how to configure a content rule for automatically archiving our portal's news.

plone_content_rules.pngContent rules are one of the most powerful and flexible tool of Plone. They allow us to configure a set of parameters and actions - rules, indeed - to be applied automatically to our contents.

Each rule can be applied to specific content types and activated or deactivated only for specific sections of the site. The actions associated to the rule can be fired by a workflow state change or from fields been updated, etc.

Use case

One common use case is to move content into another section of the portal. The simplest example in this case is archiving obsolete news and events.

The integrator / developer usually has two options: develop something specific and verticalized for customer's needs, or take advantage of content rules. In this last case he/she obtains two main benefits

  • drastically reduce the implementation time;
  • delegate creation and management of rules to site admins.

Here we are going to show how to go the 'content rules way'.

A ready-to-use solution: group by data

The content rules integration package (plone.app.contentrules) allows the developer / integrator to create custom actions. To solve our problem we'll use an existing package that already does what we need: sc.contentrules.groupbydate.

sc.contentrules.groupbydate is a package - developed by the cool team of Simple Consultoria - that defines a new action called "Move an item to a date-based folder structure". By activating this product into your portal you will be able to configure an action that once fired will move the content into a new date-based path configurable from the rule itself.

A video is worth thousands of words

In this video we'll see how to configure a content rule that will use date grouping.

NOTE: to highlight the 'archiving activity' we previously created a new workflow state called 'Archived' in order to hook our rule to the 'archived' transition.

http://youtu.be/a9HWTtM2nPM

More than one action on the same state: let's use transitions!

In this case we used as 'hook', as action trigger, our change of state. In a recent project we had the need to archive the same type of content (News) in the same workflow state (Archived) in different archives (folders). The decision on the type of archiving had to be left to the editors.

This is the solution adopted:

  • created a new state 'Archived'
  • created a set of transitions to change the state to 'Archived': 'Archive news 1', 'Archive news 2', 'Archive news N', etc.
  • hooked every rule to a different transition

In this way we can move the news archived with 'Archive news 1' into a path that differs from the news archived using the transition 'Archive news 2' and so on.

Conclusions

We saw how easy is to benefit from this powerful tool that - we want to highlight - is part of a basic Plone (!). So, the next time you need to automatize actions on your contents, before starting developing your custom solution... think about this post! :)

References

Some useful links:

Share this on

Share |

On same topics

Comments

comments powered by Disqus