We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8489
    • 90 Posts
    I have a TV assigned to the template of the home page,
    Now I want to display the output from that tv to be shown on a different template.

    I tried to call it with this snippet, but nothing shows up.

    <?php
    $value = $modx->resource->getTVValue('nameoftv');
    return $value;


    Can some one give me some advice to handle this?

    Thanks!
      • 34075 ☆ A M B ☆
      • 130 Posts
      Untested, but this should work:
      <?php
      $tv = $modx->getObject('modTemplateVar', array('name' =>'TV1'));
      echo $tv->getValue($modx->resource->get('id'));
      ?>
      
        Jeroen Kenters

        MODX Professional | MODX Ambassador | Dutch MODX forums moderator

        website | twitter
        • 8489
        • 90 Posts
        Thanks Jeroen,

        I tried your code and it works!


          • 8489
          • 90 Posts
          Is it possible to have it show up without assigning the TV to the template?
          The TV from the home page is a Listbox where you can choose resources from who will be shown on the homepage like product of the month.

          If I use the code I have to set the listbox again on other resources, Is it possible choose from the listbox from the homepage tv and have it show up automatically on all other templates?

            • 34075 ☆ A M B ☆
            • 130 Posts
            I think this is what you need: http://rtfm.modx.com/display/ADDON/getResourceField

            Just set TV on homepage and show the TV value everywhere in your template using this snippet.
              Jeroen Kenters

              MODX Professional | MODX Ambassador | Dutch MODX forums moderator

              website | twitter
              • 8489
              • 90 Posts
              Thanks Jeroen for the link!!!
                • 41907 ☆ A M B ☆
                • 8 Posts
                Bryte Digital Dialogues Reply #7, 13 years, 10 months ago
                Hi Jeroen,

                I know it´s a old post but maybe you can help me:

                I have this snippet that should parse the input value for TV superboxelect (http://modx.com/extras/package/superboxselect):

                <?
                $page = $modx->getObject('modResource', 5);
                return $page->getTVValue('superboxselect');

                ?>

                But so far, I get only the ids and I need the names (string) with a a link to the resource.

                Hope you can help me.

                Regards.

                Quote from: jeroenkenters at Jun 03, 2011, 06:55 AM
                Untested, but this should work:
                <!--?php
                $tv = $modx--->getObject('modTemplateVar', array('name' =>'TV1'));
                echo $tv->getValue($modx->resource->get('id'));
                ?>
                
                  Web development (Barcelona, Spain)

                  ..............................................
                  Bryte Digital Dialogues
                  ..............................................
                  Calle Nicaragua 48 5º 5ª,
                  08029 Barcelona, Spain

                  [email protected]
                  T +34 93 419 64 39

                  www.bryte.es
                  www.bryte.nl