We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37242 ☆ A M B ☆
    • 339 Posts
    Dear nerds,

    i really would like to display the descripion of a TV.
    I have some 60 or so TVs and would like to display something like this:
    <table border="1">
    <tr><td>[[*dtnwp]]</td><td>[[*descriptionOf[[*dtnwp]]whichMeansDistanceToNextWaypoint]]</td></tr>
    </table>
    


    I didnt find a hint so far.

    Best Regards,

    Guido
      • 4172
      • 5,888 Posts
      try this(untested) :

      create snippet ’getTvDescription’:

      <?php
      //[[!getTvDescription? &tvname=`myTv`]]
      
      $tvname=$modx->getOption('tvname',$scriptProperties,'');
      
      if ($tv=$modx->getObject('modTemplateVar',array('name'=>$tvname))){
      	return $tv->get('description');
      }
      
      return '';


      call it:

      [[!getTvDescription? &tvname=`myTv`]]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 37242 ☆ A M B ☆
        • 339 Posts
        Thank you a lot!

        How do I get all TVs of the same category? That is another thing I did not find by searching.
          • 4172
          • 5,888 Posts
          you can try something like this snippet (also untested):

          <?php
          //[[!getTvs? &category=`myCategoryId` &tpl=`tvInfo`]]
          
          $category=$modx->getOption('category',$scriptProperties,'');
          $tpl=$modx->getOption('tpl',$scriptProperties,'');
          
          $c=$modx->newQuery('modTemplateVar');
          
          if (!empty($category)){
          	$c->where(array('category'=>$category));
          }
          
          if ($collection=$modx->getCollection('modTemplateVar',$c)){
          	foreach ($collection as $object){
          		$output.=$modx->getChunk($tpl,$object->toArray());
          	}
          }
          
          return $output;


          with this chunk ’tvInfo’:

          <tr><td>[[*[[+name]]]]</td><td>[[+description]]</td></tr>



            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 37242 ☆ A M B ☆
            • 339 Posts
            Nope sad

            Where do I find the documentation on that? It really drives me nuts...
            The descriptions dont show up in the manager and with errors in the frontend output if entered via the ajax layer (quick create).
            That method seems not to use utf8 encoding sad

            Wwhen this job is done, I promise to donate to modx smiley
              • 37242 ☆ A M B ☆
              • 339 Posts
              I entered them all manually but am still interested in a package of that function.

              I guess thet this usage applies quite often.
                • 7327
                • 195 Posts
                Hi,

                Anyone know if this code will work in Evo?
                  • 3749
                  • 24,544 Posts
                  Quote from: diatomin at Sep 23, 2011, 12:38 AM
                  Hi,
                  Anyone know if this code will work in Evo?

                  Definitely not. It's strictly Revolution code.

                  You could do the same thing in Evo, but you'd have to write very different code.
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting