[BLOSSOM-154] Useful Component Inheritance Use Case Created: 03/Dec/13  Updated: 19/Dec/14  Resolved: 19/Dec/14

Status: Closed
Project: Blossom
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Neutral
Reporter: TLN Assignee: Tobias Mattsson
Resolution: Workaround exists Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
duplicate
duplicates MAGNOLIA-5418 Rendering should not fail on single a... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:

 Description   

A very typical use case on many websites that I know is this:
You have a header area, and any header component that you place there should be inherited by all child pages because typically pages use the same header. Yet, there are a few child pages that do not want to inherit the header, they want to have their own one. There are several reasons for that, sometimes you need additional disclaimers linked, specific language selector links, highlight certain menu items, etc.

I tried a lot to find an elegant out-of-the-box way to implement this, these are the results (only relevant attributes are given below, and when I say "header" it's just an example of course):

1. @Area(type=AreaType.LIST) @Inherits(components=ComponentInheritanceMode.ALL)
--> You can only add another header on a sub-page but not ignore the inherited one. So you end up with several headers on the page.

2. @Area(type=AreaType.LIST) @Inherits(components=ComponentInheritanceMode.FILTERED)
--> You can ignore the inherited one, that's very close, but then that non-inheritance is general and effects all children, not just one single page that wants to specifically override the header.

3. @Area(type=AreaType.SINGLE)
@Inherits(components=ComponentInheritanceMode.ALL)
--> Exception on the sub-page with the intended header override: Can't render single area [node ...]: expected one component node but found more.

And so on (I'm not listing all possible combinations; I'm sure you have an idea).

What I think is that case 3. should work as needed for that header use case; it's the natural assumption that when you define SINGLE and you place a header on any child page, that implicitely nothing is inherited and it only uses its own newly defined header.

Thanks.



 Comments   
Comment by Tobias Mattsson [ 19/Dec/14 ]

The functionality provided out of the box with the annotated API solves many cases but will sometimes not be sufficient to solve specific requirements. In such cases I would recommend iterating the page structure in your page controller building a list of the components to render and passing it on to the view via the model.

1) In this case you'd iterate upwards until there's a page where a header component is present.

2) In this case you'd let the author decide if the header component should effect only the page its on only or also sub pages.

3) This has been solved in MAGNOLIA-5418

Generated at Sun Feb 11 23:30:40 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.