We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15871
    • 105 Posts
    Hi everyone,

    I have a series of TV’s associated with a bunch of documents, I’d like the detail page to output the checked-off TV’s as a UL list. Any ideas?

    Thanks in Advance,
    Chuck smiley
      • 4172
      • 5,888 Posts
      can you show an example what you mean with that?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 15871
        • 105 Posts
        Hi Bruno17.

        I have a TV set o for a template that is displayed as a check box when editing the document:

        TV: optionsList
        Value: option1==Option 1||option2==Option 2||option3==Option 3||option4==Option 4

        The user selects option1 & option2 when editing the document.

        What I want to do now is display the output of the TV selections on the front end as:

        <ul>
        <li>Option 1</li>
        <li>Option 2</li>
        </ul>
        


        Thoughts?
          • 4172
          • 5,888 Posts
          don’t know if there is a ready solution. But you can try this:

          <?php
          
          //[!tvToList? &tvname=`yourtv`&docid=`yourdocid`!]
          
          $docid=isset($docid)?$docid:$modx->documentObject['id'];
          $tv=$modx->getTemplateVar($tvname,'*',$docid);
          $value=$tv['value'];
          $array=explode('||',$value);
          if (count($array)>0){
          $output='<ul>';
          foreach ($array as $value){
          $output.='<li>'.$value.'</li>';
          }
          $output.='</ul>';
          }
          return $output;
          
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 15871
            • 105 Posts
            Beautiful. Works like a charm!

            Thanks much smiley

            You should pop this into the repository.