We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51285
    • 11 Posts
    Hi all, is there a way i can create some tvs in one resource that are then used on all resources, for example footer links and logos. It seems silly to expect a client to have to update them on every page.

    sorry if its been posted before which i'm sure it will have, but unable to find any info on this issue.

    many thanks
    James
      • 20413
      • 2,877 Posts
      - You can create global system settings for this!
      https://rtfm.modx.com/revolution/2.x/administering-your-site/settings/system-settings/
      https://www.youtube.com/watch?v=HDlL-YGpALQ

      - Or you can create MODX placeholders (in a plugin or snippet) that can easily be used in the content [[+myPlaceholder]]

      - Or you can use something like pdoField to grab a value stored in a resource
      http://docs.modx.pro/en/components/pdotools/snippets/pdofield

      BUT

      What you want to learn about is MODX Chunks!! Which are global html "chunks" perfect for header, footer etc.
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 13428 ☆ A M B ☆
        • 1,031 Posts
        @mrhaw: What if you don't want to give your clients a possibility to edit chunks.

        @biffyn: I use ClientConfig for this. It creates a sort of global system settings in a separate CMP. Ideally for frequent changes of i.e. opening times in the footer, mail address for the contact form etc.
          • 13428 ☆ A M B ☆
          • 1,031 Posts
          For footer links the 'selections' part from Collections is quite usable.
            • 51285
            • 11 Posts
            thanks Jako will check it out
              • 25803 ☆ A M B ☆
              • 721 Posts
              We set up an Admin document using an Admin template for global Template Variables.
              Then we setup a context setting we call (you can call it whatever you want): admin_page_id
              We input the page ID into the Context Setting and then save it.

              This allows the client to go into the Admin page and change any TVs you've made accessible to them. We usually heavily modify this page using Manager Customization (formerly Forms Customzation and still called that in the docs) so they only see the Template Variables tab (which we also rename using Manager Customization).

              Then in chunks that reference those values (such as a [[$footer]] we use fastField (fastField Docs)to grab the value, i.e.

              [[#[[++admin_page_id]].tv.facebookAddress]]


              Where the TV is facebookAddress and the value would be their Facebook URL. So we'd have something like this within the footer chunk:

              <a class="btn btn-facebook" href="[[#[[++admin_page_id]].tv.facebookAddress]]" target="_blank">
                <i class="fa fa-facebook fa-2x"></i>
              </a>
              


              Other options are of course those mentioned above but keep in mind that ClientConfig is not context sensitive (the last I checked) so if you use multiple contexts (we do all the time but we realize not everyone does) then it's not as useful.

              You could also use context settings themselves but it's usually not a good idea to give clients access to such sensitive settings.
                • 25803 ☆ A M B ☆
                • 721 Posts
                Another method you can use is to install PDOTools and reference the admin page for a context:

                [[pdoField?&id=`[[++admin_page_id]]`&field=`facebookAddress`]]
                


                So for a Facebook link you might do this:

                <a class="btn btn-facebook" href="[[pdoField?&id=`[[++admin_page_id]]`&field=`facebookAddress`]]" target="_blank">
                  <i class="fa fa-facebook fa-2x"></i>
                </a>
                


                The reason I mention PDOTools is it supposed to be great for performance (i.e. speed).
                  • 3749
                  • 24,544 Posts
                  You can also just use chunks and use the permission system to hide them from low-level Manager users.
                    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