Hi Guys,
Your extensive modx knowledge is required!
Can anyone tell me how to create a global variable rather than just a tv? eg How do I update a phone number once, and then it filter through the entire site where [*telephonenumber*] is used?
Many thanks
One method could be to create a new snippet with the following code:
<?php
/* global_placeholders
*/
$modx->setPlaceholder('telephone_number', '123-456-7890'); // [+telephone_number+]
?>
Add the snippet call to the top of your template(s):
[!global_placeholders!]
Add the placeholder call wherever you want the number to appear:
[+telephone_number+]
Thanks breezer. I’d like to be able to change the number from a text area or rte. I’m assuming this wouldn’t be possible this way, and I’d have to change the snippet?
You could also use a chunk:
create a new chunk (which can be edited via rte).
add the phone number to the content of the chunk.
add the chunk call where you want the number to appear - {{ChunkName}}