We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Quote from: shorewalker at Sep 27, 2012, 10:02 PM
    Ben, thanks for the context settings idea. Is there a reason why creating, say, a siteFacebookAccount chunk that references your Facebook address context setting is better than just filling in the siteFacebookAccount chunk for each new site? What am I missing here?

    It all depends on the content of your chunk, we typically had a social media chunk that had all social media icons with links so the chunk would look something like this:

    <ul>
    [[++facebook:!empty=`<li><a href="[[++facebook]]" target="_blank"><img src="assets/facebook.png" alt="Facebook"/></a></li>`]]
    [[++twitter:!empty=`<li><a href="[[++twitter]]" target="_blank"><img src="assets/twitter.png" alt="Twitter"/></a></li>`]]
    </ul>
    


    So this chunk was shared in all sites but they each had unique links because each site has a unique Context Setting, we did the same thing with the contact forms we used context settings for the email to send the form to and the redirect.

    I made a trick article on CMSTricks about Context Settings check it out here
      Benjamin Marte
      Interactive Media Developer
      Follow Me on Twitter | Visit my site | Learn MODX
    • That is an excellent tip! I sort of knew about context settings, but never realized the full potential.
        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
        • 3749
        • 24,544 Posts
        It helps to understand that, as far is MODX is concerned, settings are just settings. When parsing a page, it doesn't even know where they came from. If you use a setting tag:

        [[++settingName]]


        You'll get the value of a User Setting if one with that name is set. If not, you'll get a Context Setting if one with that name is set. If not, you'll get the System Setting.

        IOW, User Settings override Context Settings and Context Settings override System Settings.

        Technically, before parsing any tags on a page, MODX loads the System Settings, then it loads the Context Settings (which will overwrite any System Settings with the same key), then it loads the User Settings for the current user (which will overwrite anything already loaded with the same key).
          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