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

Skipping component inclusion programmatically

Avatar

Level 4

Hello,

I'm trying to skip the component inclusion programmatically. The idea is to have some kind of business logic on server side that before the page composition, cycles on all components included in the page and can decide based on some condition whether or not include the components. I have been studying Sling Filters with COMPONENT scope but I couldn't find a way to actually skip the component inclusion.

Thanks

 

Stefano

1 Accepted Solution

Avatar

Correct answer by
Level 4

You can use data-sly-test/data-sly-include in the main .html of your component. That would work in any situation, static or dynamic.

The "problem" that I see with this approach is the client side library of your component. It would be part of the final .js/.css of your page no matter what.

Regards,

Daniel.

View solution in original post

5 Replies

Avatar

Employee

I would use data-sly-test and data-sly-include

Avatar

Level 4

Hi Feike,

thanks for your response! Would this solution work for pages where I don't have the data-sly-includes in the code, i.e. pages with parsys where I don't know which and how many components are included? The need is to cycle on components included in the page, regardless if that happens by drag & drop or "static" inclusion with data-sly-resource.

Thanks!

Avatar

Correct answer by
Level 4

You can use data-sly-test/data-sly-include in the main .html of your component. That would work in any situation, static or dynamic.

The "problem" that I see with this approach is the client side library of your component. It would be part of the final .js/.css of your page no matter what.

Regards,

Daniel.

Avatar

Employee

Not if you include your css/js in the header and footer of your page.

Avatar

Level 4

Feike Visser wrote...

Not if you include your css/js in the header and footer of your page.

 


Yeah. I've thought something similar later.

I believe that the problem that I've described would only happen if you're using the same category for all your components...
If you have a different category for each one of them and an include instruction for each category (as part of the component code), you won't face that kind of problem.

Regards,

Daniel.