We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11206
    • 73 Posts
    hello

    i was wandering what the best way was to use a variable that is being set in one snippet in another snippet?

    is that possible?
      • 4041
      • 788 Posts
      the simplest way I know is to set a placeholder with the needed info, then print the results in another snippet.

      For example: I added a snippet to the top of the template before anything else with this code -

      [!SendVariable!]
      <?php
      $sentvariable ="yes";
      $modx -> setPlaceholder('sentvariable', $sentvariable);
      ?>


      This will set up a placeholder to use later in the script and will print the word yes
      wherever you add the placeholder tags - [+sentvariable+]

      $output .="[+sentvariable+]";
      // prints "yes"


      a simple example, but it can be modified any way you need...  smiley

      also have a look here:
      http://wiki.modxcms.com/index.php/API:setPlaceholder
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 11206
        • 73 Posts
        thanks breezer - that’s exactly what i needed! cheers.