4

Is it possible to show shared site rendering variant at the top of variant drop down?

Currently, We have rendering variant in shared site and actual site and it is showing actual site rendering variant at the top after that shared site rendering variant. We would like to show shared site rendering variant at the top of dropdown?

1 Answer 1

3

There is a pipeline called getVariants. It's responsible for creating the list of available variants. You would need to rearrange processors there:

<getVariants>
    <processor type="Sitecore.XA.Feature.Composites.Pipelines.GetVariants.SwitchPageTemplateId, Sitecore.XA.Feature.Composites" resolve="true"/>
    <processor type="Sitecore.XA.Foundation.Variants.Abstractions.Pipelines.GetVariants.GetSystemVariants, Sitecore.XA.Foundation.Variants.Abstractions" resolve="true"/>
    <processor type="Sitecore.XA.Foundation.Variants.Abstractions.Pipelines.GetVariants.GetSiteVariants, Sitecore.XA.Foundation.Variants.Abstractions" resolve="true"/>
    <processor type="Sitecore.XA.Foundation.Variants.Abstractions.Pipelines.GetVariants.GetLinkedVariants, Sitecore.XA.Foundation.Variants.Abstractions" resolve="true"/>
    <processor type="Sitecore.XA.Foundation.Variants.Abstractions.Pipelines.GetVariants.GetSharedVariants, Sitecore.XA.Foundation.Variants.Abstractions" resolve="true"/>
    <processor type="Sitecore.XA.Foundation.Variants.Abstractions.Pipelines.GetVariants.FilterVariants, Sitecore.XA.Foundation.Variants.Abstractions" resolve="true"/>
</getVariants>

GetSharedVariants should be before GetSiteVariants processor.

Patch file like this should do the trick:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"
               xmlns:env="http://www.sitecore.net/xmlconfig/env/"
               xmlns:role="http://www.sitecore.net/xmlconfig/role/">
  <sitecore>
    <pipelines>
      <getVariants>
        <processor type="Sitecore.XA.Foundation.Variants.Abstractions.Pipelines.GetVariants.GetSharedVariants, Sitecore.XA.Foundation.Variants.Abstractions">
          <patch:delete />
        </processor>
        <processor type="Sitecore.XA.Foundation.Variants.Abstractions.Pipelines.GetVariants.GetSharedVariants, Sitecore.XA.Foundation.Variants.Abstractions"
          resolve="true"
          patch:before="processor[@type='Sitecore.XA.Foundation.Variants.Abstractions.Pipelines.GetVariants.GetSiteVariants, Sitecore.XA.Foundation.Variants.Abstractions']" />
      </getVariants>

    </pipelines>
  </sitecore>
</configuration>

Your Answer

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

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