We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32396
    • 56 Posts
    Quote from: sharkbait at Feb 21, 2010, 03:53 PM

    Yeah!!! I did it ))
    great! smiley

    ...thought it needs to be dynamic ( e.g. automatically assigning a new class if you add another TV value / without editing the snippet )

    I’m not so good at programming so I did what I can.
    I will be grateful if you make it dynamic smiley
      Using: MODx Evo 1.0.6 / Revo 2.2.5
      • 20413
      • 2,877 Posts
      That code is excellent for what you want! smiley
      I first thought you wanted an integer number for some jQuery function.
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 3749
        • 24,544 Posts
        This might make it dynamic and a little faster (untested):

        <?php
        // Use snippet [[UsedTools?id=[+id+] ]] in Ditto call template
        // TV Input Option values: Flash==Flash#ico-flash||HTML==HTML#ico-html||CSS==CSS#ico-css||JS==JS#ico-js||PHP==PHP#ico-php||MySQL==MySQL#ico-mysql
        
        $output = "";
        $document_tvs = $modx->getTemplateVarOutput(true, $id);
        $TVvalue = $document_tvs['tools'];
        $TVarray = explode(",",$TVvalue);
        
        	foreach ($TVarray as $val) {
                    $valArray=explode("#",$val);
                    $output .= '<span class="' . $valArray[0] . '">'. $valArray[1] . '</span>';
        	}
        
        return $output;
        ?>



          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
          • 3749
          • 24,544 Posts
          I just noticed that the names are regular, so I think it could also be done even faster with your original input option values like this:

          <?php
          // Use snippet [[UsedTools?id=[+id+] ]] in Ditto call template
          // TV values: Flash||HTML||CSS||JS||PHP||MySQL
          
          $output = "";
          $document_tvs = $modx->getTemplateVarOutput(true, $id);
          $TVvalue = $document_tvs['tools'];
          $TVarray = explode(",",$TVvalue);
          
          	foreach ($TVarray as $val) {
          
             	    $output .= '<span class="ico-'. strtolower($val) . '">' . $val. '</span>';
          
          	}
          
          return $output;
          ?>


            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
            • 32396
            • 56 Posts
            Quote from: BobRay at Feb 22, 2010, 01:26 AM

            I just noticed that the names are regular, so I think it could also be done even faster with your original input option values like this:

            <?php
            // Use snippet [[UsedTools?id=[+id+] ]] in Ditto call template
            // TV values: Flash||HTML||CSS||JS||PHP||MySQL
            
            $output = "";
            $document_tvs = $modx->getTemplateVarOutput(true, $id);
            $TVvalue = $document_tvs['tools'];
            $TVarray = explode(",",$TVvalue);
            
            	foreach ($TVarray as $val) {
            
               	    $output .= '<span class="ico-'. strtolower($val) . '">' . $val. '</span>';
            
            	}
            
            return $output;
            ?>




            Thanks a lot! This is perfect !
              Using: MODx Evo 1.0.6 / Revo 2.2.5
              • 3749
              • 24,544 Posts
              Quote from: Wild at Feb 22, 2010, 03:20 AM

              . . .
              Thanks a lot! This is perfect !

              Don’t thank me until it works. wink
                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