0

I am trying to add a class 'feed-test' to 'template-one' based on the boolean value of a checkbox property on 'template-two.' I have read through this similar post regarding block statements, but still struggling.

Here's the file structure and code:

Directory structure

structure/
├── template-one/ 
│   ├── body.html
│   └── .content.xml   
└── template-two/
      ├── _cq_dialog 
      │   └──  .content.xml
      └── other files
   

template-one where i need to add class

<div class="base-wrapper INSERT-FEED-TEST-CLASS-HERE">
<sly data-sly-use.templatedContainer="com.day.cq.wcm.foundation.TemplatedContainer"
     data-sly-repeat.child="${templatedContainer.structureResources}"
     data-sly-resource="${child.path @ resourceType=child.resourceType, decorationTagName='div'}"/>

template-two class property i need to access

<isFeedPage
    cq:showOnCreate="{Boolean}true"
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
    cq-msm-lockable="isFeedPage"
    fieldLabel="Is Feed Page"
    text="Is Feed Page"
    name="./isFeedPage"
    granite:class="feed-test">
                                                
participant
  • 2,923
  • 2
  • 23
  • 40
Emma Earl Kent
  • 498
  • 5
  • 12
  • I am not 100% sure, but the question itself feels wrong, because page != template and also template != component. If you are actually talking about content (pages and instances of components) then you have SlingModels, the current request and with that you can get all the data you might need. – Oliver Gebert Feb 16 '22 at 07:11

1 Answers1

0

This is a good place for HTL's Use API: you need to deploy some code that will be able to retrieve the needed template (using TemplateManager#getTemplate for example) and fetch the needed property.

Then you'd use it like:

<div data-sly-use.classProvider="MyClassProvider" class="base-wrapper ${classProvider.className}">
...
</div>
Vlad
  • 10,602
  • 2
  • 36
  • 38