Skipping component inclusion programmatically | Community
Skip to main content
Level 4
March 13, 2017
Solved

Skipping component inclusion programmatically

  • March 13, 2017
  • 5 replies
  • 2450 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by daniel_henriqu1

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.

5 replies

Feike_Visser1
Adobe Employee
Adobe Employee
March 13, 2017

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

boser87Author
Level 4
March 13, 2017

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!

daniel_henriqu1
daniel_henriqu1Accepted solution
Level 4
March 13, 2017

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.

Feike_Visser1
Adobe Employee
Adobe Employee
March 13, 2017

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

daniel_henriqu1
Level 4
March 13, 2017

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.