3

Does anyone know how to change the order of the conditional rendering rules when you try to personalize a component? I've added a custom rule that I'd like to show up at the top of the list, but it's buried somewhere in the middle, because it seems to be purely alphabetical. I see that the "Predefined Rules" are always at the top, which tells me that this must be possible, I'm just doing it wrong.

So far I have tried the following, to no avail:

  • moving my custom tags to the top of the Conditional Rendering's default multiselect
  • changing the sort order of my custom tags
  • changing the sort order of my custom element

Can anyone point me in the right direction?

1 Answer 1

2

Dug in a little after I saw your question and it appears that the Predefined Rules are handled as a special case;

Within Sitecore.Shell.Applications.Rules.RulesEditor.RulesEditorPage and in the GetGroupedElements method there is an OrderBy involving a static ID RulesEditorPage.PredefinedRulesItemId. After trying to follow the decompiled logic, my assumption is that the Predefined Rules are weighted at the top and then the order by falls back to Element Folder name. If that is the case, prefixing your Element Folder name with an underscore or adding your rules to the Predefined Rules Element Folder would likely get them visible toward the top (though neither one of those seems like a perfect solution).

Further note: if you are interested in digging in more, there are 3 processors that get executed out of box during the RulesEditorPage (in Sitecore 9.0.1 at least):

<getRenderedRuleElements>
    <processor type="Sitecore.Pipelines.Rules.Taxonomy.GetContextFolder, Sitecore.Kernel"/>
    <processor type="Sitecore.Pipelines.Rules.Taxonomy.GetTags, Sitecore.Kernel"/>
    <processor type="Sitecore.Pipelines.Rules.Taxonomy.GetElementFolders, Sitecore.Kernel"/>
</getRenderedRuleElements>

These pipelines effectively find and aggregate the rules for a given Tags Definition under the Rules Context Folder (the multi-list that is sortable and relates your rules to let's say the Insert Options rule). The result of this getRenderedRuleElements pipeline is what gets passed into the RulesEditorPage and eventually ordered and rendered when you click Edit Rule. I will update my answer if I find anything else while I continue to dig.

Hope this helps.

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.