Contentful logo

Contentful Community

How to set up rules in CMS?

Hi, I am wondering if its possible to set up specific rules governing content creation in the CMS.

Specifically, I have a content type “Blog Post”, with a boolean field “Featured” in order to display a featured post on a home page. I want the CMS user to only be able to designate one post as featured, so if they try to do so either they have to unmark the current “featured” as featured…or more ideally if they save a new post as “featured” then it will set the other one to false.

Is it possible to do this??

I believe this is not possible with boolean values.

But there is a workaround that can lead to the same effect with text/number value.

Create a text field, name it accordingly and in the Validation tab tick the Unique field, next you also tick the Accept only specified values and add for example featured (later on you can create some “tags” if you want).

That’s it, now you can use the delivery API to retrieve the featured blog post with
fields.field_name=featured

This will work just fine - thank you!