Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Skipping component inclusion programmatically

boser87
Level 4
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
daniel_henriqu1
Correct answer by
Level 4
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
Feike_Visser1
Employee
Employee

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

boser87
Level 4
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!

daniel_henriqu1
Correct answer by
Level 4
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

Feike_Visser1
Employee
Employee

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

daniel_henriqu1
Level 4
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.