We launched new forums in March 2019—
join us there
.
In a hurry for help with your website?
Get Help Now!
Back to MODX.com
Forums
Docs
Revo Issues
Blog
My Forums
General
General Support
Search
php101 question, defining a variable.
104 Posts
scraf
Reply #1,
20 years, 4 months ago
... 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
☆ A M B ☆
24,524 Posts
sottwell
Reply #2,
20 years, 4 months ago
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
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
104 Posts
scraf
Reply #3,
20 years, 4 months ago
That syntax was straight from some instructions I had, too much ActionScript as it goes.
☆ A M B ☆
24,524 Posts
sottwell
Reply #4,
20 years, 4 months ago
I knew there was some reason I didn’t care for Flash!
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
104 Posts
scraf
Reply #5,
20 years, 4 months ago
Well with ActionScript 2.0 it would be....
var id:Number = 1;