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

    I hope someone can help me. I am php illiterate...sorry. I am designing a site with multiple color variations available. Currently I have to change the template of every resource if someone chooses another color. I am searching for a simple script or snipit that would create a drop down in the resource editor, where the user could simply select their choice of color from a list and the script would dynamically change one word in the headerchunk which is the stylesheet name. The one word in the header (such as blue, green, or red) is the only difference in the html for the templates. It would be best if this could be accomplished by a manager user with minimal permisssions. Please advise.

    Thanks
      • 7231
      • 4,205 Posts
      You could use the method int he wiki post on creating TV based CHunks:
      http://wiki.modxcms.com/index.php/Create_TV-Based_Chunks

      You could also just have a select TV (pull down select or combo box) with the options for the colors you want and use the output of the TV to set the color.
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 14022
        • 21 Posts
        Worked perfect!! grin I wish I wasn’t such a PHP bonehead. It’s great to have such good community support!
        Thanks a ton!
          • 14022
          • 21 Posts
          Do you know if there is a way to make it site wide for all templates and pages?
            • 7231
            • 4,205 Posts
            Not sure, but I would look at using the @INHERIT binding to make it so the selection is inherited by all the children of that section.
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don't know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Do you mean that editing its value in one page will change it for the default? No, that’s not how it works. Editing on a single page only changes it for that page, and if it’s a parent and the default is @INHERIT, for its children.

              However, you could use a plugin, using OnDocFormSave, to change the TV’s default value to match the one set for the document.
                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
                • 14022
                • 21 Posts
                would that allow a change made to one resource to change all of the other resources in the site tree. My objective is to find a simple way to change themes without repetition. Such as changing the color by linking to alternate stylesheets from the header chunk which would be made sitewide.
                  • 14022
                  • 21 Posts
                  How do I find the plugin you mentioned "OnDocFormSave" and accompanying documentation? I am unable to find it by searching extras or by the search feature.

                  Thanks for your help!
                    • 3749
                    • 24,544 Posts
                    Doesn’t DocManager allow you to change multiple TV values? That might be easier than trying to write a plugin.
                      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
                      • 14022
                      • 21 Posts
                      I was looking at doc manager and it looked like it might do the trick. Do you have any idea as to what the sytnax would be. I look at the example, and all of the supporting documentation I can find, and I see huh??????????? If I knew what it was expecting, it seems to be a simple enough task to achieve.

                      Thanks for your help