コミュニティアチーブメントバーを展開する。

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

この会話は、活動がないためロックされています。新しい投稿を作成してください。

解決済み

request.getAttribute in Sightly expression

Avatar

Level 1

I have a site where we're setting some request attributes that are used across the whole page via a JS-use file:

// requestAttributes.js

use(function(){

    request.setAttribute('testAttribute","test attribute value");

});

And sightly markup that looks like this

<sly data-sly-use.atts="requestAttributes.js">

    <html>

        <sly data-sly-include="head.html" data-sly-unwrap/>

        <sly data-sly-include="body.html" data-sly-unwrap/>

        <sly data-sly-include="footer.html" data-sly-unwrap/>

    </html>

</sly>

 

Is there a way to access the request attributes natively in Sightly (i.e. ${request.attributes["testAttribute"]})?  I know that I could write a second js-use file to act as a getter for retrieving the attribute value, but ideally I'd like to do access it straight from the markup rather than having data-sly-use files in all of my include files.

 

Thanks!

1 受け入れられたソリューション

Avatar

正解者
Administrator

Hi jmccoskery

As mentioned by Scott and Praveen, you can go through the article mentioned by them.

Apart from the article mentioned by then here are few more reference article that can be looked upon :-

Link:- http://aempodcast.com/2015/sightly/emulating-requestscope-variables-sightly-aem/#.VkWQ6LcrLRY

Link:- http://labs.6dglobal.com/blog/2015-01-23/accessing-request-variables-sightly/

Link:- http://blogs.adobe.com/experiencedelivers/experience-management/sightly-intro-part-4/

Link:- http://stackoverflow.com/questions/25430981/are-there-requestscope-variables-in-sightly

I hope this would help you.

 

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

元の投稿で解決策を見る

4 返信

Avatar

Level 10

Avatar

Level 10

Avatar

正解者
Administrator

Hi jmccoskery

As mentioned by Scott and Praveen, you can go through the article mentioned by them.

Apart from the article mentioned by then here are few more reference article that can be looked upon :-

Link:- http://aempodcast.com/2015/sightly/emulating-requestscope-variables-sightly-aem/#.VkWQ6LcrLRY

Link:- http://labs.6dglobal.com/blog/2015-01-23/accessing-request-variables-sightly/

Link:- http://blogs.adobe.com/experiencedelivers/experience-management/sightly-intro-part-4/

Link:- http://stackoverflow.com/questions/25430981/are-there-requestscope-variables-in-sightly

I hope this would help you.

 

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

Avatar

Level 5

FYI since labs.6dgloba.com is down, here's a link to the same post about accessing request variables in Sightly (HTL) on my personal blog: https://www.danklco.com/posts/2015/01/23/accessing-request-variables-sightly/