sightly template to populate model class data | Community
Skip to main content
Level 4
Aug 18, 2017 6:28 AM UTC
Solved

sightly template to populate model class data

Hi All,

I have a requirement, where i will take input from author in <body> via component and display it in <head> section of the page. e.g. any script tag.

I am trying to use <data-sly-template>. Though, i am getting all values when i am using simple text. But when i am trying to access model class variables, i am getting null or no data.

    This is working fine: (written in component html and accessed in another html via data-sly-call)

       <template data-sly-template.tags>

                 some random text

       </template>

I want this, and its not working: (same as above)

<template data-sly-template.tags>

     ${tagModel.tagContent}

</template>

Info:I am creating the template in component html and want to use it in basePage.html.

         if i try to print  ${tagModel.tagContent} in the component html, i am getting value of tagContent.

Please help.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Feike_Visser1
Feike_Visser1Accepted solution
Employee
Aug 21, 2017 12:40 PM UTC

try page properties, without jcr:content

${pageProperties['iparsys/custom_tag/tagcontent']}

18 replies

Feike_Visser1
Employee
Aug 21, 2017 1:26 PM UTC

It is the same, the path is unique.

Translate
Level 4
Aug 21, 2017 1:25 PM UTC

Something more complex with this:

Though earlier answer was right. Just an extension of the same.

What if we have many or more than 1 custom_tag components available in iparsys?

Translate
Level 4
Aug 21, 2017 1:01 PM UTC

It worked.

Thanks a lot for your valuable support, time and patience.

Translate
Feike_Visser1
Feike_Visser1Accepted solution
Employee
Aug 21, 2017 12:40 PM UTC

try page properties, without jcr:content

${pageProperties['iparsys/custom_tag/tagcontent']}

Translate
Level 4
Aug 21, 2017 12:28 PM UTC

here "tagcontent" is a property for custom_tag component.

I tried all the approaches, but getting null.

${properties['jcr:content/iparsys/custom_tag'].tagcontent}

${properties['jcr:content/iparsys/custom_tag\tagcontent']}

Still no luck.

Translate
Feike_Visser1
Employee
Aug 21, 2017 10:47 AM UTC

${properties['jcr:content/iparsys/custom_tag/tagcontent']}

Translate
Level 4
Aug 21, 2017 9:36 AM UTC

So you mean:

${properties[jcr:content/iparsys/custom_tag].tagcontent}" ??

Translate
Feike_Visser1
Employee
Aug 21, 2017 8:16 AM UTC

Sure you can do something like ${pageProperties['a/b/c']}

Translate
Level 4
Aug 21, 2017 8:06 AM UTC

hey Fieke,

Thanks for reference.

I am facing an issue here, i am passing the values of model class from base page to component template.

Since, the properties are not available in base page i am getting null.

Is there a way i can access child parsys properties from parent page.

Base page

     jcr:content

          parsys

               tagComponent  <-- i want to read this component properties in basePage.html

Translate
smacdonald2008
Level 10
Aug 18, 2017 2:31 PM UTC

Thanks Feike for your awesome community help

Translate