1

I have a page which is having many controller rendering but I want to execute only some of them based on any condition. Is it possible to do it in sitecore programmatically?

3
  • 2
    You can apply personalization rule to hide that rendering or you can pass some rendering parameter so on the basis of that parameter you can show/hide the component Jan 3, 2020 at 5:47
  • Actually i am calling web api and from there i am checking the condition if it is true then only i have to show otherwise i have to hide. Jan 3, 2020 at 6:27
  • How about having a common condition in code which will be triggered for all such controller renderings. Please provide some more detail to attract better solutions.
    – sukesh
    Jan 3, 2020 at 9:43

1 Answer 1

3

To do the same follow below steps:

  1. First you need to create custom personalization rule.
  2. Write you custom code which will inherit RuleContext Class, for check the condition where you will match value one which comes from web API and other you set in your rule.
  3. If both the value will be matched then show or hide your rendering bases on the condition.

For more details how to create custom Personalization rule, You can find more details here: Custom Personalization Rules in Sitecore

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.