skip to Main Content

So say you have a component that is being used in the body section of a page. I want to take specific values from the text fields of that component and write them to the of the html file.

I have a tile list component, with a title text field and a description rich text field.


                            <div class="col box-title">${tileitems.properties.title @ context='html'}</div>
                            <div data-sly-test='${description}' class="col">
                                <p>${tileitems.properties.rte || tileitems.properties.description @ context='html'}</p>
                            </div>

How can I get the values that are authored into the component and write on the same page but to the head of the html.

do i need a java model for this ? any examples thanks

2

Answers


  1. You have (at least) two options:

    1. Append the needed markup to head from your content component using JavaScript.
    2. Create an Use Object (Java/Sling Model) and walk the descendants tree searching for the specific resource type and properties and expose the data you need. Use this to append the needed markup in the head.
    Login or Signup to reply.
  2. Another option is to extend the page properties, instead of a component in the body. Then, you can read them directly in the head.html

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search