May 9, 2020
Estimated Post Reading Time ~

Shared menu

Requirements
  • Configurable;
  • Cannot be removed by an author;
  • Shared between a root page and every descendant of this page (children, grandchildren, …), even if they use different templates or page components;
  • Editable only from the root page.
Step by step solution
  1. Add an iparsys to the root page template and a menu instance to this iparsys;
  2. Statically include the menu instance in the root page component;
  3. Create a page template and a page component for the descendant pages;
  4. Add an empty iparsys to the descendant page template, using the same name of the iparsys defined in (1);
  5. Include that iparsys in the descendant page component, setting its wcmmode to disabled;
  6. You may also need
How does it work?
Iparsys takes care of the content inheritance between a page and its child pages. Since we have a single instance of iparsys (the one defined at the root page template), we’ll end up with all descendants referring to the exact same instance.

By including the menu instance in the root page component instead of including its container iparsys, we disable the author’s ability to move/remove the menu instance and the ability to add more components to that iparsys.

Then setting wcmmode to disabled, at the descendant page component, is enough to ensure that an author won’t be able to break or override the iparsys inheritance.

As usual, a sample project can be found on GitHub.



By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.