We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33992 ☆ A M B ☆
    • 455 Posts
    Hi,
    I had a checkbox TV for selecting custom JS/CSS resources to add to pages header in 2.0.7.
    Input options was like below:
    Some Label==<!-- Some Label --><link href="path/to/some.css" rel="stylesheet" type="text/css" /><script type="text/javascript" src="path/to/some.js"></script>||Some Another Label==<!-- Some Another Label --><link href="path/to/someother.css" rel="stylesheet" type="text/css" /><script type="text/javascript" src="path/to/someother.js"></script>

    But after upgrading to 2.1, TV fields in manager broke and i see some broken JS codes instead.
    Is it a bug? or Users can’t use quotations and slashes in input options?


    Thanks
    AHHP
      God loves me. 【ツ】


      MODX.ir (Persian Support)

      Boplo.ir/modx/ (Persian)
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You might want to try using chunks instead; put your code in the chunk and use the chunk tags in the input options of the TV.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 33992 ☆ A M B ☆
        • 455 Posts
        Just want to report such issue, I solved my problem with a small snippet.
        Thanks for your help.
          God loves me. 【ツ】


          MODX.ir (Persian Support)

          Boplo.ir/modx/ (Persian)
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I prefer to use snippets for these as well.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 17249 ☆ A M B ☆
            • 165 Posts
            I use a snippet for this, comes very handy for keeping the need of different templates to a minimum.
            Just insert the snippet call in the content field or a TV (or direct call in the template) and scripts are automatically added to the head or the end of the page.
            Excellent for me. Easier to maintain.

            scripts_map Snippet:

            <?php
            
            //adding scripts before the </head> tag 
            $modx->regClientStartupScript('assets/templates/myTemplate/js/jquery/jquery-1.4.4.min.js');
            $modx->regClientStartupScript('assets/templates/myTemplate/css/map.css');
            
            //adding scripts before the </body> tag
            $modx->regClientScript('assets/templates/myTemplate/js/jquery-gmap3-3.2/gmap3.js');
            


            And then call [[scripts_map]] in a template, or a content field in a resource or even a template variable where you can add more of them like
            [[scripts_map]] [[scripts_slideshow]]

            Of course if you’re going to use jquery sitewide makes sense to place this call directly in the template with normal <script></script> tags. tongue
            This makes more sense for page specific scripts or widgets with javascript.


            More info about it in the docs:
            http://rtfm.modx.com/display/revolution20/Adding+CSS+and+JS+to+Your+Pages+Through+Snippets