OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.37k stars 1.12k forks source link

Implement visibility rules for individual content items #7283

Open bedegaming-aleksej opened 7 years ago

bedegaming-aleksej commented 7 years ago

As a CMS admin, I want to be able to specify visibility conditions for individual content / menu items in CMS so I do not have to create a separate layer for every item I want to hide under a specific condition. This would allow me to have less content duplication, so it would be easier to manage the site content.

Justification Assume the following situation:

Suggested solution

ViRuSTriNiTy commented 7 years ago

I don't fully get the justification but i had to solve a similar task. Perhaps my approach by using a custom part can help you out in a way or another. You can find the question and answer here: http://stackoverflow.com/questions/37684524/how-to-skip-displaying-a-content-item-in-orchard-cms

ifle commented 7 years ago

+5. The visibility conditions for individual content / menu items are very important for us too @ViRuSTriNiTy Thanks for sharing your solution

bedegaming-aleksej commented 7 years ago

The solution I have is slightly different. I am going to submit a pull request with it soon, but in essence, I have a part that interprets layer rules reusing the layer rules engine. Based on the result of the validation the content item is either displayed or hidden. For now, this is done with an empty alternate view. Compared to @ViRuSTriNiTy 's solution, it achieves more flexibility as layer rules could include all sorts of conditions, but, on the other hand, it does mean that even when the content item should not be visible as a result of the rule validation, it would go through the whole handler / driver / etc pipeline anyway. I will investigate if it is possible to combine the best of the two.

sebastienros commented 7 years ago

A part sounds reasonable, good idea.