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;









3

















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?










share|improve this question
































    3

















    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?










    share|improve this question




























      3












      3








      3








      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?










      share|improve this question















      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






      share|improve this question














      share|improve this question











      share|improve this question




      share|improve this question










      asked May 29 at 11:30









      Niti ChauhanNiti Chauhan

      1094 bronze badges




      1094 bronze badges























          2 Answers
          2






          active

          oldest

          votes


















          2


















          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).






          share|improve this answer


























          • 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


















          2


















          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.






          share|improve this answer



























            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
            );



            );














            draft saved

            draft discarded
















            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









            2


















            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).






            share|improve this answer


























            • 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















            2


















            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).






            share|improve this answer


























            • 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













            2














            2










            2









            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).






            share|improve this answer














            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).







            share|improve this answer













            share|improve this answer




            share|improve this answer










            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

















            • 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













            2


















            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.






            share|improve this answer






























              2


















              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.






              share|improve this answer




























                2














                2










                2









                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.






                share|improve this 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.







                share|improve this answer













                share|improve this answer




                share|improve this answer










                answered May 29 at 14:08









                Richard SealRichard Seal

                16.3k3 gold badges31 silver badges65 bronze badges




                16.3k3 gold badges31 silver badges65 bronze badges































                    draft saved

                    draft discarded















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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









                    Popular posts from this blog

                    Tamil (spriik) Luke uk diar | Nawigatjuun

                    Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                    Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?