We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20180
    • 29 Posts
    I have a tv of listbox type with options like

    OptionTXT1==1||OptionTXT2==2||OptionTXT3==3 and so on..

    Now if I use [[+tv.tvname]] in a getResources template or just straight [[*tvname]] in a document what I get is the 1,2,3.. values.

    Is there a way to get the names instead? Like OptionTXT1, OptionTXT2... ?

    I know there is an extra http://modx.com/extras/package/gettvdisplayname that should do it but it doesn't work - when I try to use it somewhere I get 500 Internal Server Error...

    Can You suggest an output filter or a snippet that will get the name instead of value???


    THANKS

    Montag
    Apache 2.2.24 + Php 5.3.27 + MODX REVO 2.2.9
      Kind Regards
      ====================
      montagproject
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Any reason why your values have to be 1,2,3?
      Option1==Option1||Option2==Option2
        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
        • 41592 ☆ A M B ☆
        • 83 Posts
        I think you have to use modx API, make a getObject on modTemplateVar, then you can call something like $object->get(). Take a look here http://api.modx.com/revolution/2.1/_model_modx_modtemplatevar.class.html
        Maybe could be getDisplayParams() ? Let me know [ed. note: solidusite last edited this post 13 years ago.]
          Francesco Mussoni | MODX Ambassador | Skype: solidusite2 | Email: [email protected]
          • 20180
          • 29 Posts
          Quote from: sottwell at Oct 20, 2013, 10:17 PM
          Any reason why your values have to be 1,2,3?
          Option1==Option1||Option2==Option2

          Unfortunately yes. If I will do it that simple here it will complicate the code elsewhere smiley
            Kind Regards
            ====================
            montagproject
            • 20180
            • 29 Posts
            Quote from: solidusite at Oct 20, 2013, 11:42 PM
            I think you have to use modx API, make a getObject on modTemplateVar, then you can call something like $object->get(). Take a look here http://api.modx.com/revolution/2.1/_model_modx_modtemplatevar.class.html
            Maybe could be getDisplayParams() ? Let me know

            Thanks, I will look into it... Never tried to use MODX Api before, but... Maybe it's time smiley
              Kind Regards
              ====================
              montagproject
              • 20180
              • 29 Posts
              Update. I got getTvDisplayName to work. It was a trailing ? at the end of the snippet, that caused 500 Internal Server Error... however none of the API methods available didn't work, what effectively could get what I wanted from the TV was...

              <?php
              if ($tvn) {
              
              /* Get the TV */
              $tv = $modx->getObject('modTemplateVar',array('name'=>$tvn));
              
              /* get TV elements */
              
              $elements = $tv->get('elements');


              $tvn is the TV passed to the snipped as parameter and get('elements') method is stolen from getTvDisplayName extra.

              It renders all TV content in one string + indicates the key that was chosen.

              Thanks.

                Kind Regards
                ====================
                montagproject