We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24629
    • 370 Posts
    Hi all,
    When i have a snippet [[MySnippet]] that creates a variable $myVariable.
    is it possible to use that variable somewhere else on the page/template

    <body>
    [[MySnippet]]
    
    [[myvariable]]
    </body>


    Tnx Rdg
      • 38705
      • 101 Posts
      if your snippet outputs to placeholders this shouldn't be a problem.

      in your snippet add:
      <?php
      ...your_snippet_code_here...
      $modx->setPlaceholder('PlaceHolderName',$yourvariable);
      

      instead of using
      return $yourvariable;


      upon calling the snippet your variable will be available in modx:
      in the example use: [[+PlaceHolderName]]
      Goodluck coding!
        Addict since 2012....