Diese Konversation wurde aufgrund von Inaktivität geschlossen. Bitte erstellen Sie einen neuen Post.
Level 1
Level 2
Melden Sie sich an, um alle Badges zu sehen
Diese Konversation wurde aufgrund von Inaktivität geschlossen. Bitte erstellen Sie einen neuen Post.
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.
Gelöst! Gehe zu Lösung.
try page properties, without jcr:content
${pageProperties['iparsys/custom_tag/tagcontent']}
Zugriffe
Antworten
Likes gesamt
Can you share a bit more code than this?
It is not clear to me exactly where the issue is.
Zugriffe
Antworten
Likes gesamt
Where are you initializing the tagModel object ? If you are doing that in component HTML and expecting it to be available in base page then it won't be available since base page will always be rendered before the component inside the <body> tag. You should initialize the model object in base page HTML itself.
Zugriffe
Antworten
Likes gesamt
file: custom_tag_template.html
<sly data-sly-use.customTagModel="com.barclays.aem.bccl.core.models.CustomtagModel">
${customTagModel.tagcontent} <-- this works fine, i can see tagcontent on page
<template data-sly-template.tag>
${customTagModel.tagcontent} <--so I made it a template
</template>
</sly>
file: basePage.html
calling template values using data-sly-call, since template is present other file data-sly-use is used
<sly data-sly-use.tags="/apps/myproject/components/content/custom_tag/custom_tag_template.html">
<sly data-sly-call='${tags.tag @ tagContent="${properties.priority}"}'> <--this is null
Zugriffe
Antworten
Likes gesamt
Kunal,
Please refer the code i sent now.
I am initializing the the tagModel in component html. retrieving value from it and creating template.
I tried initializing tagModel object in base page as well, but the values were null.
Zugriffe
Antworten
Likes gesamt
Can you pass in the model into the template?
Zugriffe
Antworten
Likes gesamt
You need to define parameters in your data-sly-template.
Also remember that only the data-sly-template gets executed when it is called externally.
Zugriffe
Antworten
Likes gesamt
I passed model into template.
How do i use model parameters in template so that when i call it externally, i get the model data?
Any reference to the same will be appreciated.
Zugriffe
Antworten
Likes gesamt
Here you find the reference: https://docs.adobe.com/docs/en/htl/docs/block-statements.html#template & call
Zugriffe
Antworten
Likes gesamt
Thanks Feike for your awesome community help
Zugriffe
Antworten
Likes gesamt
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
Zugriffe
Antworten
Likes gesamt
Sure you can do something like ${pageProperties['a/b/c']}
Zugriffe
Antworten
Likes gesamt
So you mean:
${properties[jcr:content/iparsys/custom_tag].tagcontent}" ??
Zugriffe
Antworten
Likes gesamt
${properties['jcr:content/iparsys/custom_tag/tagcontent']}
Zugriffe
Antworten
Likes gesamt
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.
Zugriffe
Antworten
Likes gesamt
try page properties, without jcr:content
${pageProperties['iparsys/custom_tag/tagcontent']}
Zugriffe
Antworten
Likes gesamt
It worked.
Thanks a lot for your valuable support, time and patience.
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?
Zugriffe
Antworten
Likes gesamt
It is the same, the path is unique.
Zugriffe
Antworten
Likes gesamt
Zugriffe
Likes
Antworten
Zugriffe
Likes
Antworten