We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26439
    • 104 Posts
    ... if I was handcoding php I would put this in the source.

    <?php
    var id = 1;
    ?>
    


    Er, how do I do that within the ModX framework ? It seems to be too basic a concept to have been including in the documentation.

    Firstly for a single page, secondly for every page ?

    TIA

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I would put
      $id = 1;
      

      whether in a .php file or a snippet or TV.

      Now if I’m trying to get the ID of the current page, it would depend on where I was. Usually you can use
      [*id*]
      

      or if within some php code,
      $modx->documentIdentifier
      


      Usually a string (such as the output for a snippet) is initialized like this:
      $output = '';


      Have you been working with javascript code lately wink
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 26439
        • 104 Posts
        That syntax was straight from some instructions I had, too much ActionScript as it goes. undecided
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I knew there was some reason I didn’t care for Flash! grin
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 26439
            • 104 Posts
            Well with ActionScript 2.0 it would be....

            var id:Number = 1;