Uploaded image for project: 'Magnolia Personalization'
  1. Magnolia Personalization
  2. MGNLPN-224

Getting the siteRoot from a variant page fails

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Neutral Neutral
    • 1.2.1
    • 1.2
    • None
    • None
    • Sprint 2 (Basel)
    • 5

      Given a page structure like this:

      • home (template-type ‘home’)
        • variants
          • variant-0
          • variant-1
        • bla-feature (template-type ‘feature’)

      using any templating functions like cmsfn.page(content) or cmsfn.siteRoot(content) on one of the variants will return the variant and not the actual ‘home’-page.
      So when you e.g. want to find a page with template-type ‘feature’ it won’t start searching from the actual site-root ‘home’ but from the variant and therefor fail.

      info.magnolia.templating.functions.TemplatingFunctions#contentListByTemplateType(..., siteRoot, ..)
      info.magnolia.rendering.template.type.TemplateTypeHelper#getContentListByTemplateIds
      

      The path returned here is /home/variants/variant-0 because of info.magnolia.personalization.decoration.PersonalizationNodeWrapper#getPath returning the path of the wrapped node and not the original.

      #getPath returns the path to variant on purpose because it’s the only way to differentiate whether we’re dealing with a variant and changing it would probably need significant changes to the page editor. OTOH it seems a bit misleading as other overridden methods do take the original node into account.

      We worked around this problem in MGNLDEMO-79 but for fixing e.g. MGNLDEMO-78 we would again have to work around this issue.

      Proposed fix:
      One proposal which works and is committed to branch is to have p13n replace and override the TemplatingFunctions by a variant-aware one, which overrides the affected functions, in this case #page(content) will make sure we get the page and not the variant.

      Problem: It’s an easy fix, but there might be customers already replacing the TemplatingFunctions. Besides that what do you expect when you call #page(content)? The page or the variant of the page?

        Acceptance criteria

              ejervidalo Espen Jervidalo
              ejervidalo Espen Jervidalo
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD

                    Estimated:
                    Original Estimate - 1d 7h
                    1d 7h
                    Remaining:
                    Remaining Estimate - 1d 7h
                    1d 7h
                    Logged:
                    Time Spent - Not Specified
                    Not Specified