I’m very new to Modx about 2 weeks old and just had a difficult time re-thinking the way I write my PHP. (Probably because I was not born very smart.)
Im very sure there is an easier or maybe more elegant/recomended way of doing this, but I had to post this just in case someone else out there is like me.
Here is my snippet:
<?php //test_snippet for simple placeholders
$first = 'Joe';
$last = 'Shmoe'; // I think that's how its spelled.
$mynumber = '777'; //Feeling lucky
$modx->setPlaceholder('first',$first);
$modx->setPlaceholder('last',$last);
$modx->setPlaceholder('number',$mynumber);
//That's it for the snippet.
?>
This could be in either a chunk or inside the actual content. I put this in my content, just to keep it simple.
<p>My Name is: [+first+]. My Last Name is: [+last+]. My Lucky number is: [+mynumber+].</P>
To my astonishment it worked and displayed this.
My Name is: Joe. My Last Name is: Shmoe. My Lucky number is: 777.
I read this post a few times which helped me realize how simple this really could be. My primary purpose for doing this was to create a prefilled fird with data from a custom table.
http://modxcms.com/forums/index.php?topic=43393.0
II am very open to suggestions whic will surely add to the enlightment. I’d like to put them into an array and then call them just like above. maybe even like [+myarray.first+], etc, but I have not tested or tried that.
So is it pronounced "mod-ex" like modular x or like mode-ex?