<![CDATA[ Global template variables - MODX Community Forums]]> https://forums.modx.com/thread/?thread=98802 <![CDATA[Global template variables]]> https://forums.modx.com/thread/98802/global-template-variables#dis-post-534270
sorry if its been posted before which i'm sure it will have, but unable to find any info on this issue.

many thanks
biffyn Nov 11, 2015, 05:47 PM https://forums.modx.com/thread/98802/global-template-variables#dis-post-534270
<![CDATA[Re: Global template variables]]> https://forums.modx.com/thread/98802/global-template-variables#dis-post-547388 BobRay Dec 16, 2016, 08:03 AM https://forums.modx.com/thread/98802/global-template-variables#dis-post-547388 <![CDATA[Re: Global template variables]]> https://forums.modx.com/thread/98802/global-template-variables#dis-post-547367 PDOTools and reference the admin page for a context:


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>

The reason I mention PDOTools is it supposed to be great for performance (i.e. speed).]]>
rx2 Dec 15, 2016, 04:14 PM https://forums.modx.com/thread/98802/global-template-variables#dis-post-547367
<![CDATA[Re: Global template variables]]> https://forums.modx.com/thread/98802/global-template-variables#dis-post-534498 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.


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>

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.]]>
rx2 Nov 17, 2015, 12:18 PM https://forums.modx.com/thread/98802/global-template-variables#dis-post-534498
<![CDATA[Re: Global template variables]]> https://forums.modx.com/thread/98802/global-template-variables#dis-post-534495 biffyn Nov 17, 2015, 10:48 AM https://forums.modx.com/thread/98802/global-template-variables#dis-post-534495 <![CDATA[Re: Global template variables]]> https://forums.modx.com/thread/98802/global-template-variables#dis-post-534282 Collections is quite usable.]]> Jako Nov 12, 2015, 02:43 AM https://forums.modx.com/thread/98802/global-template-variables#dis-post-534282 <![CDATA[Re: Global template variables]]> https://forums.modx.com/thread/98802/global-template-variables#dis-post-534281
@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.]]>
Jako Nov 12, 2015, 02:40 AM https://forums.modx.com/thread/98802/global-template-variables#dis-post-534281
<![CDATA[Re: Global template variables]]> https://forums.modx.com/thread/98802/global-template-variables#dis-post-534271 https://rtfm.modx.com/revolution/2.x/administering-your-site/settings/system-settings/

- 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


What you want to learn about is MODX Chunks!! Which are global html "chunks" perfect for header, footer etc.]]>
mrhaw Nov 11, 2015, 06:51 PM https://forums.modx.com/thread/98802/global-template-variables#dis-post-534271