Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Same header across all pages in website

Avatar

Level 2

Hi

I am quite new in AEM.

Have one usecase : In my project, i have to create 40 templates , 400 pages of the website, and i want to have same header on all pages. how is this possible ?

Approach 1 : I created one base component (sling : resourcesupertype is foundation/component/page) - base which includes base.jsp and header.jsp

Header.jsp consists of all HTML structure required for header.

Base.jsp includes header.jsp using cq:include

Then created base template that points to base component.

then created a basepage using base template, it successfully includes header.

Now want this header in other pages as well.

Created ABC component with sling : resourceSuperType - basecomponent

created ABC template refers to ABC component.

created ABCPage using ABC template.

But it doesn't display header.

please tell me what i am missing. Have used this approach by seeing geometrix project.

Approach 2 : in 1st approach, have done through by creating header.jsp, but now want to do it by creating header component.

and want to include header component on every page. i guess that can be done through iparsys. let me know how's that possible.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi Suman

          In your approach 1, when you created the ABC template, does it's page component (ABC) follow the sling principles ?

          If you need your head.jsp to get included in all pages of all the templates, make sure you follow the sling principles. A small attempt to explain the same has been done in this question Template component can't override page.html . The principal of sling resolution remains same as explained in there.

      If you refer geometrixx you will see that the contentpage template has only one jsp content.jsp .

1266021_pastedImage_0.png

This will pretty much solve your below problem

I am pretty much concerned about 40 templates ( that is really not acceptable for a neat architecture of your website.).  If this is some project you are working for any client, I think you have to check with your architect and redesign this . I would always recommend to have very less templates . To decide how many templates you need, you should really work with the UI and decide on the variation in the layout.

     For one of our project we acheived around 5 layouts with one template by simple using some column control components . The website was designed using bootstrap and so we could make a generic component to bring the layouts. I would not say you should do that, but at least 40 templates should not be the case. We should always focus on making the life of authors easy rather than making it hard

Coming back to your Approach 1, I could see you are talking about only header.jsp and so I assume your header will not be authorable and you are going to hard code everything ( which again I will never recommend) . You can either use a design_dialog , if you are planning to create a component for approach one. But then for every template you have to author it seperately.

Approach 2 is my favorite for that matter (I don't stick to this approach always ) . I know many may not recommend it , but if you are going to have only one root page, then you can create that with base template and have iparsys and drag and drop header to it and then it should work magic for you.

Thanks

Veena

View solution in original post

3 Replies

Avatar

Level 3

For 1st approach : I guess, you have created the abc.jsp. If yes, then it wont include base.jsp file which actually include your header file.

So, the approach should be like : in base component, create body.jsp, and base.jsp. Base.jsp should include body and header  jsp.

Now in Abc component, you create body.jsp and write the html code related to this component. This should include the header.jsp in all pages.

For approach 2 : iparsys works on template level. So, if you have included the header component in iparsys of a page component, it'll appear in all its children's pages with same template.

Avatar

Correct answer by
Community Advisor

Hi Suman

          In your approach 1, when you created the ABC template, does it's page component (ABC) follow the sling principles ?

          If you need your head.jsp to get included in all pages of all the templates, make sure you follow the sling principles. A small attempt to explain the same has been done in this question Template component can't override page.html . The principal of sling resolution remains same as explained in there.

      If you refer geometrixx you will see that the contentpage template has only one jsp content.jsp .

1266021_pastedImage_0.png

This will pretty much solve your below problem

I am pretty much concerned about 40 templates ( that is really not acceptable for a neat architecture of your website.).  If this is some project you are working for any client, I think you have to check with your architect and redesign this . I would always recommend to have very less templates . To decide how many templates you need, you should really work with the UI and decide on the variation in the layout.

     For one of our project we acheived around 5 layouts with one template by simple using some column control components . The website was designed using bootstrap and so we could make a generic component to bring the layouts. I would not say you should do that, but at least 40 templates should not be the case. We should always focus on making the life of authors easy rather than making it hard

Coming back to your Approach 1, I could see you are talking about only header.jsp and so I assume your header will not be authorable and you are going to hard code everything ( which again I will never recommend) . You can either use a design_dialog , if you are planning to create a component for approach one. But then for every template you have to author it seperately.

Approach 2 is my favorite for that matter (I don't stick to this approach always ) . I know many may not recommend it , but if you are going to have only one root page, then you can create that with base template and have iparsys and drag and drop header to it and then it should work magic for you.

Thanks

Veena