How to read a field in the variant template?Using #if in SXA variant NVelocity templateHow to configure SXA Search Box to support tab or enter completion?How do you properly configure SXA Page List with custom query?“Could not find the rendering in the HTML loaded from server” when adding custom rendering to SXAFilter Dropdown datasourceHow to display PDF link in Sitecore pageHow to change name of external link when viewing in its rendering variant?Checklist field value in Search Results in SXASXA Custom Experience Button for Page Content Rendering Variant FieldHow do you configure the Tabs component to use a custom item template for the webedit button?
Is This Constraint Convex?
What are modes in real world?
Ping more than 56 bytes on macOS
Volrath's Shapeshifter, Static Buffs, and Combat damage
Covering an 8x8 grid with X pentominoes
What do I get by paying more for a bicycle?
Program to print the multiple occurrence of numbers in a list
Why are Buddhist concepts so difficult?
Why do the new Star Trek series have so few episodes in each season?
How do I search for a package?
How are hillsides farmed?
Could the principle of owls' silent flight be used for stealth aircraft?
Why is Elastic Net called Elastic Net?
A pencil in a beaker of water
How can I increase the rate of regeneration in humans without the possibility of tumors developing?
Python algorithm that converts array-like data into MathJax
Copying files: does Windows write to disk if files are identical?
Why does hairspray work as an adhesive for ABS?
How to handle a player wanting to use the (UA) Remote Access spell on an android player character?
Does recycling lead to less jobs?
Is there a name for the phenomenon of false positives counterintuitively outstripping true positives
Why is Robin Hood French in Shrek?
How to make the following format
You see a boat filled with people
How to read a field in the variant template?
Using #if in SXA variant NVelocity templateHow to configure SXA Search Box to support tab or enter completion?How do you properly configure SXA Page List with custom query?“Could not find the rendering in the HTML loaded from server” when adding custom rendering to SXAFilter Dropdown datasourceHow to display PDF link in Sitecore pageHow to change name of external link when viewing in its rendering variant?Checklist field value in Search Results in SXASXA Custom Experience Button for Page Content Rendering Variant FieldHow do you configure the Tabs component to use a custom item template for the webedit button?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
The requirement is to return the item id in the query string on button click.
I added a template in the rendering variant and added the following line
<a href="https://some url?itemid=$item.ID">Button text</a>
Now, I want button text to come from the sitecore field. $item.fieldName is not working. What is the right way of reading the text from the sitecore field in this case?
sxa
add a comment
|
The requirement is to return the item id in the query string on button click.
I added a template in the rendering variant and added the following line
<a href="https://some url?itemid=$item.ID">Button text</a>
Now, I want button text to come from the sitecore field. $item.fieldName is not working. What is the right way of reading the text from the sitecore field in this case?
sxa
add a comment
|
The requirement is to return the item id in the query string on button click.
I added a template in the rendering variant and added the following line
<a href="https://some url?itemid=$item.ID">Button text</a>
Now, I want button text to come from the sitecore field. $item.fieldName is not working. What is the right way of reading the text from the sitecore field in this case?
sxa
The requirement is to return the item id in the query string on button click.
I added a template in the rendering variant and added the following line
<a href="https://some url?itemid=$item.ID">Button text</a>
Now, I want button text to come from the sitecore field. $item.fieldName is not working. What is the right way of reading the text from the sitecore field in this case?
sxa
sxa
asked May 29 at 11:30
Niti ChauhanNiti Chauhan
1094 bronze badges
1094 bronze badges
add a comment
|
add a comment
|
2 Answers
2
active
oldest
votes
I am in doubt now that Dawid says it doesn't exist ootb, but I have something like this working:
$item.Fields.BookLink.ToString()
where "BookLink" is the name of my field. Hopefully your field does not have a space in the name ;)
The "ToString" was needed in our case as we wanted to check if it was empty (see Using #if in SXA variant NVelocity template).
Yep, this will work!
– Dawid Rutkowski
May 29 at 11:59
Thanks . @Gatogordo Can you please tell me how to read the link of the current item in the same case.
– Niti Chauhan
May 30 at 14:06
add a comment
|
In addition to the method that @Gatogordo suggested you can use this method if your field has spaces in the name:
$item.Fields.get_Item("A Field With Spaces")
You can add .ToString()
in the same way as it is used in the other answer.
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "664"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f19020%2fhow-to-read-a-field-in-the-variant-template%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I am in doubt now that Dawid says it doesn't exist ootb, but I have something like this working:
$item.Fields.BookLink.ToString()
where "BookLink" is the name of my field. Hopefully your field does not have a space in the name ;)
The "ToString" was needed in our case as we wanted to check if it was empty (see Using #if in SXA variant NVelocity template).
Yep, this will work!
– Dawid Rutkowski
May 29 at 11:59
Thanks . @Gatogordo Can you please tell me how to read the link of the current item in the same case.
– Niti Chauhan
May 30 at 14:06
add a comment
|
I am in doubt now that Dawid says it doesn't exist ootb, but I have something like this working:
$item.Fields.BookLink.ToString()
where "BookLink" is the name of my field. Hopefully your field does not have a space in the name ;)
The "ToString" was needed in our case as we wanted to check if it was empty (see Using #if in SXA variant NVelocity template).
Yep, this will work!
– Dawid Rutkowski
May 29 at 11:59
Thanks . @Gatogordo Can you please tell me how to read the link of the current item in the same case.
– Niti Chauhan
May 30 at 14:06
add a comment
|
I am in doubt now that Dawid says it doesn't exist ootb, but I have something like this working:
$item.Fields.BookLink.ToString()
where "BookLink" is the name of my field. Hopefully your field does not have a space in the name ;)
The "ToString" was needed in our case as we wanted to check if it was empty (see Using #if in SXA variant NVelocity template).
I am in doubt now that Dawid says it doesn't exist ootb, but I have something like this working:
$item.Fields.BookLink.ToString()
where "BookLink" is the name of my field. Hopefully your field does not have a space in the name ;)
The "ToString" was needed in our case as we wanted to check if it was empty (see Using #if in SXA variant NVelocity template).
answered May 29 at 11:50
GatogordoGatogordo
14k2 gold badges22 silver badges71 bronze badges
14k2 gold badges22 silver badges71 bronze badges
Yep, this will work!
– Dawid Rutkowski
May 29 at 11:59
Thanks . @Gatogordo Can you please tell me how to read the link of the current item in the same case.
– Niti Chauhan
May 30 at 14:06
add a comment
|
Yep, this will work!
– Dawid Rutkowski
May 29 at 11:59
Thanks . @Gatogordo Can you please tell me how to read the link of the current item in the same case.
– Niti Chauhan
May 30 at 14:06
Yep, this will work!
– Dawid Rutkowski
May 29 at 11:59
Yep, this will work!
– Dawid Rutkowski
May 29 at 11:59
Thanks . @Gatogordo Can you please tell me how to read the link of the current item in the same case.
– Niti Chauhan
May 30 at 14:06
Thanks . @Gatogordo Can you please tell me how to read the link of the current item in the same case.
– Niti Chauhan
May 30 at 14:06
add a comment
|
In addition to the method that @Gatogordo suggested you can use this method if your field has spaces in the name:
$item.Fields.get_Item("A Field With Spaces")
You can add .ToString()
in the same way as it is used in the other answer.
add a comment
|
In addition to the method that @Gatogordo suggested you can use this method if your field has spaces in the name:
$item.Fields.get_Item("A Field With Spaces")
You can add .ToString()
in the same way as it is used in the other answer.
add a comment
|
In addition to the method that @Gatogordo suggested you can use this method if your field has spaces in the name:
$item.Fields.get_Item("A Field With Spaces")
You can add .ToString()
in the same way as it is used in the other answer.
In addition to the method that @Gatogordo suggested you can use this method if your field has spaces in the name:
$item.Fields.get_Item("A Field With Spaces")
You can add .ToString()
in the same way as it is used in the other answer.
answered May 29 at 14:08
Richard Seal♦Richard Seal
16.3k3 gold badges31 silver badges65 bronze badges
16.3k3 gold badges31 silver badges65 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Sitecore Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f19020%2fhow-to-read-a-field-in-the-variant-template%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown