Extra parameters in data-sly-resource | Community
Skip to main content
David_Woollard
New Participant
October 16, 2015
Solved

Extra parameters in data-sly-resource

  • October 16, 2015
  • 13 replies
  • 27225 views

I am trying to implement something which I hope is relatively straight forward...  I have one component (lets call it the wrapper component) which contains another component (lets call it the inner component) inside it via the data-sly-resource tag:

<div data-sly-resource="${ 'inner' @ resourceType='/projectname/components/inner' }"></div>

I would like to pass in some additional parameters with this tag, specifically a parameter that can be picked up by sightly in the inner component template?  I am trying to specify whether the inner templates outer html tag is unwrapped based on a parameter being passed in when the component is called via data-sly-resource.

After experimenting and perusing the sightly documentation, I can't find a way of achieving this.

Does anyone know if this is possible?

Many thanks,

Dave

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 Feike_Visser1

<div data-sly-resource="${ 'inner' @ resourceType='/projectname/components/inner', selectors='different' }"></div>

What you can do is the following:

you have your inner.html as the default, now you create a different.html file in your component. This will be used when the selector='different' is specified.

Or what you can do is to do a check in a WCMUse class whether a specific selector is specified.

Can you test the first approach?

best,

Feike

13 replies

David_Woollard
New Participant
October 16, 2015

Thank you for your help Feike, that is marvellous!

David_Woollard
New Participant
October 16, 2015

Hi Feike,

Thank you for your swift response!

I have used data-sly-template and data-sly-call elsewhere in my component and am very happy with how they work, however they do not solve the problem at hand.

Lets look at the problem another way... I have a component called Heading.  This component can be used all over the site.  If this component appears inside the Hero component then I want it to render slightly differently.  

Can you suggest a way I might achieve this?

Thanks for your help!

Dave

Feike_Visser1
Employee
October 16, 2015

hi dave,

This might work for you....

<div data-sly-resource="${ 'inner' @ resourceType='/projectname/components/inner', selectors='different' }"></div>

Now depending on the selector you can render your component in a different way.

WDYT?

best,
Feike