We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38873
    • 10 Posts
    Hi everyone, I have a bit a problem...
    I want to add a template variable to my Product template.
    The template variable should hold the radio buttons for availability (Available/Not available).
    I got so far that I create the template variable and assign it to the Product template, but what should I do next to get it appearing when browsing the product page? [ed. note: dii-ii last edited this post 14 years, 7 months ago.]
      • 30912
      • 463 Posts
      What version of MODx are you using?

      and im assuming you want the result of the TV to be either Available or Not Available on the FRONT end of the site?

      I havent had much use with Radio buttons in the back end overall, i generally use drop downs for Yes / No results which when setting it up.

      Create the TV, set the type to Listbox Single Select

      In the input values add the following: Available||Not Available

      Assign the TV to the template and then when you want to call the TV in the template just add [[*TV-Name]] or [*TV-Name*] (if evo) in the template itself.
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Radio buttons and check boxes are pretty much the same. Select the input type you want, then in the "input options" field use name==value pairs separated by double-pipes ||. The "name" will be the label of the button/box, the value will be its value when selected. Output is like any TV, in raw form simply outputting the value. Snippets can be used as custom output modifiers; especially useful for formatting the list of values for a set of checkboxes.

        While for Evo, the principles here remain the same for Revo http://wiki.modxcms.com/index.php/Adding_TV_Widgets_without_hacking_the_core
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 32330
          • 40 Posts
          The broken english is a bit trouble understand, but if I understand correctly you can simply add:

          [[$yourtvname]]


          in the template where you want it.

          or

          Add the code above in another TV or a chunk or in the content box.

          Reply back if you solved it.
            MODx helps me stay in the white
            • 1778
            • 659 Posts
            Hello
            If you want to display the content of the TV in your doc on Front-End you have to put
            [[*nameOfTvV] ( [[*...]] is the correct tag for TVs) not [[$nameOfTV]] ( [[$...]] is the tag for Chunks) in your template (as other TVs or 'system TV').

            Your template could be something like that (very light and simple) (I put some other tags for explanation)

            <body>
                <h1>[[*pagetitle]] </h1> // pagetitle is a 'system TV' but still a TV called with the tag [[*...]] 
                <p>[[!*myOwnTV]] </p> // here I call uncached (just putting the '!' at the start of the call) a TV I created,, called 'myOwnTV' and attached to my template
              <p>[[$myOwnChunk]]</p> //call of a chunk (basically a piece of HTML, the content of the chunk will be substitute to the call on display
               <p>[[myOwnSnippet]]</p> // Here I call a snippet : a piece of PHP code that will be executed at the time the page loads...
            </body>
            


            You can of course create a TV with a content that is a chunk, or a snippet
            You can create chunks to wrap snippet in.
            You can create snippet and call a chunk to display the result...
            etc...
            Hope these little examples help you to clarify...
            Cheers
              • 38873
              • 10 Posts
              Quote from: whitesphynx at Mar 03, 2012, 12:18 AM
              The broken english is a bit trouble understand, but if I understand correctly you can simply add:

              [[$yourtvname]]


              in the template where you want it.

              or

              Add the code above in another TV or a chunk or in the content box.

              Reply back if you solved it.




              It doesn't help.
              I have already created the TV and assigned it to the template I need (in this case for Product template, which uses chunk named "ProductDetails").
              When I'm creating new resource using "Product template" I see the options to choose (Available | Not available). But if I visit my webpage, I don't see that information.

              I tried what you suggested, but it still not showing anything.
                • 1778
                • 659 Posts
                what are you using as output type ?
                cheers
                  • 35082
                  • 57 Posts
                  Hello dii-ii,

                  For the output of the TV to show up on the front end of your site, then the TV must be referenced in the content field of the resource to display it.

                  example, the tag:
                   [[*nameofTV]]
                  should be placed in the content field of your document.
                    • 32330
                    • 40 Posts
                    dii-ii,

                    Sorry I put in the code for Chunk due to late night brain fart.

                    It should be a * for TV and $ for a Chunk as GregR and Anso stated, but I think you probably have that part done correctly, right?

                    Excuse my ignorance but I spoke too fast without fully comprehending your problem. I personally have not used the Radio Options TV and I assumed you were just not calling the TV correctly, but I went back and tested that TV and duplicated your issue. I see the problem you are talking about which is nothing shows up when choosing that TV type and then following the normal steps for applying the TV where you want it.

                    After a short bit of searching I found these two links that I think you will find helpful:

                    http://sottwell.com/tv-input-types.html
                    and
                    http://rtfm.modx.com/display/revolution20/Template+Variable+Input+Types#TemplateVariableInputTypes-RadioOptions
                    and I'm sure there are some more, possibly even in this forum, did you search around here?

                    With a quick skim over those links it looks to me that if the TV is a Radio Options type you need to provide more information so that MODX knows what information your Radio Button is referencing. You can find the "Input Option Values" box directly under the box where you chose the Input Type and you need values there in the form of:
                    My Option==1


                    Read through those links and see if you can figure out what you need to put in for Values. They may not address your specific function in the examples but see if you can apply it to what you are trying to do. I did notice you can target chunks with the radio option for example.

                    If you're still stuck after you give it a go post back here. Be as specific as you can. The more specific you can be and the more effort you put into working it out on your own the more likely you'll be to get a response from an advanced user who has experience with those functions.

                    Cheers and GL!
                      MODx helps me stay in the white
                      • 38873
                      • 10 Posts
                      Quote from: whitesphynx at Mar 03, 2012, 11:05 PM
                      dii-ii,


                      After a short bit of searching I found these two links that I think you will find helpful:

                      http://sottwell.com/tv-input-types.html
                      and
                      http://rtfm.modx.com/display/revolution20/Template+Variable+Input+Types#TemplateVariableInputTypes-RadioOptions
                      and I'm sure there are some more, possibly even in this forum, did you search around here?



                      Thank you a lot - this was great! Everything works just fine smiley