We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33657
    • 128 Posts
    So i was thinking. alot of clients want to change facebook, twitter, social media links.. maybe update a logo, all these things...

    so i have alot of them in template variables.

    my question is.

    Is there a better way to do this?

    right now i make a template... lets call it "Homepage Variables"

    its a blank template.

    Then I make a unpublished hidden page called Global Site Config.

    in there I have all my template variables and they are setup using Form Customization.

    Templates Vars like - Sitelogo, Twitter, Facebook, Metatags, Keywords, Google maps ID, Google analytics, etc.

    Then other templates like homepage template or sidebar template, or whatever.. they use GetResourcesField

    so all templates pull the logo but the logo is set on the one config template page.



    ok...

    so is there a better way to do this? is there a way to integrate this into the Dashboard? Can i create global variables some other way and then link them up etc.. is there a package manager plugin that does it? If not, it would be a good idea... maybe a more elegant way to do it rather than to waste a tempalte and waste a resource?

    ok thanks!
      • 19369
      • 1,098 Posts
      I do exactly the same with the only difference that I use the home page and not an unpublished resource.
        • 33657
        • 128 Posts
        ok, so you just verified that this is indeed a issue that needs proper attention. If you do and I do it, everyone must do it... in some fashion... and if they don't they could probably benefit if it was simplified. Which is why i'd love to see a Dashboard widget of some sort that handles it. has its own variables or is part of a global config or template or something (maybe the authors of modx figure this part out).

        then in your template variables you can assign a var to a template or to the master config. All master config vars goto the dashboard. etc.
          • 19369
          • 1,098 Posts
          I think you can add custom configuration fields on system settings, but if they are going to be updated by the customer probably it is not the right way of doing it.
            • 18373 ☆ A M B ☆
            • 3,141 Posts
            A client-configuration page is on my growing list of addons I want to develop when I find the time :') Though the idea of putting it on the dashboard is actually a good one I didn't of yet.

            In some cases where I've used a similar strategy I added a "Settings" link in the top menu via System > Actions & Menus, which makes it easier to explain clients where to find it.
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 33657
              • 128 Posts
              take a look at this.

              So i have a bunch of social media buttons on my footer. (Facebook, twitter, etc etc)

              In my "global page" is where i set up all my variables, and i use getresourcesfield to get the TV's. on top of that i use logic to check if they are empty and if they are, i don't show the social media button.

              [[getResourceField:notempty=`<li class="twitter"><a href="[[getResourceField? &id=`1` &field=`Twitter` &processTV=`1`]]">Follow us @mytwitterID on Twitter</a></li>`? &id=`1` &field=`Twitter` &processTV=`1`]]


              ok, so that is really ugly... i mean its elegant, but ugly...

              i'd much rather have a "global" TV variable like
              [[+GV.Twitter]] 
              (GV for global variable)

              then imagine this code instead...

              [[+GV.Twitter:notempty=`<li class="twitter"><a href="[[+GV.Twitter]]">Follow us @csssolutions on Twitter</a></li>`]]



              how do we get this into fruition?
                • 3109 ☆ A M B ☆
                • 894 Posts
                What I do is use context settings, this allows you to use settings or global variables you can access throughout the site, which is great when you have multiple contexts.

                Click on your Web context then go to you Context Settings tab then click on create new.

                On the Create New Settings pop-up enter the information for your new setting, here's an example.



                The Area Lexicon Entry lets you organize them, so if you want to add a second entry for Facebook make sure you use the same entry you used for your previous Area lexicon Entry

                To access it throughout your site just use:

                
                [[++twitter:!empty=`<li class="twitter"><a href="[[++twitter]]">Follow us @csssolutions on Twitter</a></li>`]]
                
                


                This is the best solution I have found and it works wonders especially if you have a multi context site and are sharing chunks, snippets and tpls using the context settings as the values.

                Hope that helps.
                  Benjamin Marte
                  Interactive Media Developer
                  Follow Me on Twitter | Visit my site | Learn MODX
                  • 33657
                  • 128 Posts
                  hey benmarte, thanks for taking the time to create screenshots and post.

                  Where would the client go to access this stuff? See my problem isn't really "my" problem but a clients problem, etc.. I want the client to have a page similar to a configuration page where they can go to easily update variables, like twitter, facebook, social media stuff, maybe the homepage logo, maybe a email address for the contact form.

                  would context's work for this? or would this have to be put in a special section in the settings of the site?
                    • 3109 ☆ A M B ☆
                    • 894 Posts
                    The client would have to access the context settings and update the fields you have there so they won't be able to create new ones on the fly if thats what you want then this is not a solution.

                    This will work if you want to specify some Global Variables (Context Settings) they can change and update every where they are used on your site.

                    It's not as elegant as the plugin Mark might develop but it's what I have used in the past as works without any issues.
                      Benjamin Marte
                      Interactive Media Developer
                      Follow Me on Twitter | Visit my site | Learn MODX