We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 52647
    • 9 Posts

    I have a template variable called TAGS... the input is as follows: "alpha,beta,gamma,delta". So technically thats one tag. How to separate the individual tags inside this one tag so I can apply HTML anc CSS code to them. For example, that "alpha" has border:1px solid black, and for "gamma" the same CSS style. If I apply this example CSS code on my TV TAGS, then the whole block of "alpha,beta,gamma,delta" gets the border and not the individual tags. How to do this?

    This question has been answered by breezer. See the first response.

      • 28432
      • 372 Posts
      Hi, have you try to change output TV type to : HTML Tag TV Output Type or Delimiter TV Output Type ?
        • 52647
        • 9 Posts
        Hi Steeve,

        Actually the TV-tags gets the input from a CSV file I upload and under the TV-tags the listing is like this... alpha,beta,gamma,delta

        When I change the Input-Type to your recommendations, then the tags disappear in my resouces.

        Maybe I understand your recommendation wrong. Perhaps you could provide an example of how could work?
          • 28432
          • 372 Posts
          Quote from: rbez0s at Aug 28, 2016, 03:26 PM
          When I change the Input-Type to your recommendations, then the tags disappear in my resouces.

          OUTPUT TYPE not input type, next tab in the template variable ;-)
            • 52647
            • 9 Posts
            Must be a Revolution thing because I dont see that in Evo 1.1
              • 28432
              • 372 Posts
              Quote from: rbez0s at Aug 28, 2016, 09:24 PM
              Must be a Revolution thing because I dont see that in Evo 1.1
              Yes it is! You've never said before that you were on Evolution ;-)
              • discuss.answer
                • 4041
                • 788 Posts
                Create a snippet named TAGS with the code below, and replace your TV call with the snippet call.
                eg: [*TAGS*] becomes [!TAGS!]
                Modify the $replace array as needed.

                <?php
                $tv_value = $modx->getTemplateVarOutput( array( 'TAGS' ) );
                
                $replace = array(
                           'alpha'  =>  '<a href="#" style="border:1px solid blue;">alpha</a>',
                           'gamma'  =>  '<span style="border:1px solid black;">gamma</span>'
                           );
                
                $output ='';
                $output = str_replace( array_keys( $replace ), array_values( $replace ), $tv_value['TAGS'] );
                return $output;
                ?>
                  xforum
                  http://frsbuilders.net (under construction) forum for evolution
                  • 52647
                  • 9 Posts
                  Quote from: breezer at Aug 31, 2016, 11:25 AM
                  Create a snippet named TAGS with the code below, and replace your TV call with the snippet call.

                  Thanks, breezer, that worked perfectly!... smiley