I’m using the new MODx Revolution 2.0.2-pl
I’m just trying to call a snippet from within a snippet. They look like below
I get this:
Parse error: syntax error, unexpected ’[’ in C:\xampp\htdocs\cmapp\core\cache\elements\modsnippet\2.include.cache.php on line 7
Snippet1:
[[Snippet2]]
Snippet2:
if ($modx->user->isMember(’SuperUser’)) {
return ’3’;
}
Snippet1 displays nothing. Snippet2 displays "3".
As below.
Snippet1:
$runcheck = "Snippet2";
$modx->runSnippet($runcheck);
Snippet2:
<?php
if ($modx->user->isMember(’SuperUser’)) {
return ’3’;
}
Does anyone know how to do this or how to make something like this work?
I don’t want to have to write a bunch of checks into each snippet, I’d rather call another snippet. I’d like to assign a variable in my script based on a snippet return.
Snippet1:
<?php
$runcheck = 'Snippet2';
return $modx->runSnippet($runcheck);
or:
<?php
$runcheck = 'Snippet2';
$output = $modx->runSnippet($runcheck);
return $output;
Snippet2:
<?php
if ($modx->user->isMember('SuperUser')) {
return '3';
}
I really hate it when the answer is that easy. I should have noticed the missing return.
Thanks for your help!