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

    Your extensive modx knowledge is required!

    Can anyone tell me how to create a global variable rather than just a tv? eg How do I update a phone number once, and then it filter through the entire site where [*telephonenumber*] is used?

    Many thanks
      • 4041
      • 788 Posts
      One method could be to create a new snippet with the following code:
      <?php 
      /*  global_placeholders
      
      */
      $modx->setPlaceholder('telephone_number', '123-456-7890');  // [+telephone_number+]
      ?>


      Add the snippet call to the top of your template(s):
      [!global_placeholders!]

      Add the placeholder call wherever you want the number to appear:
      [+telephone_number+]
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 9366
        • 19 Posts
        Thanks breezer. I’d like to be able to change the number from a text area or rte. I’m assuming this wouldn’t be possible this way, and I’d have to change the snippet?
          • 4041
          • 788 Posts
          You could also use a chunk:
          create a new chunk (which can be edited via rte).
          add the phone number to the content of the chunk.
          add the chunk call where you want the number to appear - {{ChunkName}}


            xforum
            http://frsbuilders.net (under construction) forum for evolution
            • 9366
            • 19 Posts
            and would I be able to make that rte available to an end user? huh
              • 23571
              • 223 Posts
              Wow, I just finished a post about this. Hope it helps!
              http://www.gregorysmart.com/2010/01/08/create-a-user-config-page-in-modx/