Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • philip knight 9 posts 30 karma points
    Sep 12, 2023 @ 21:03
    philip knight
    0

    Back Office Toggle, (checkbox) Validation

    On my Umbraco 12 site the content creator can create blog post and would like to mark a post as a feature post by adding a boolean toggle. Is there a way in back office to add validation that checks if a blog post is already marked as a feature post? I'm trying to avoid having multiple featured post.

  • Marc Goodson 2155 posts 14406 karma points MVP 9x c-trib
    Sep 12, 2023 @ 22:04
    Marc Goodson
    1

    Hi Philip

    Three possible thoughts spring to mind..

    One on your Blog Listing Document Type you could add a Multinode Tree Picker property called 'Featured Blog Post' and configure it to allow only one blog post to be picked - this solves the problem of only one post being featured, but it's an extra step for the editor to do after they've written the post.

    Alternatively you could have the checkbox on the blog post as you suggest, and then order the posts by publish date and take only the latest one as the featured post... But this won't scale well if you have hundreds of blog posts, and in scenario that someone wants an older post to be featured, they'll need to find the newer one to untick the box, so maybe the picker is easier.

    Finally to answer your question specifically, whenever you save or publish content in Umbraco, Notifications are issued which you can write c# code to handle, check the content, make other queries, and cancel the action with a message to the editor. But again telling the editor that there is another post that is featured, just means they have to find that post untick and switch back to their new one to tick box and publish, so maybe the featured blog post picker is easier? Here is some info on handling notifications...

    https://docs.umbraco.com/umbraco-cms/reference/notifications/contentservice-notifications

    What I normally do in these scenarios is by default have the latest blog post featured, but with the Featured Blog Post picker to override this in the niche circumstance when an older blog post needs to be sticky!

    Regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft