Hi,
I'm new to modx and I'm trying to write a snippet, which calls a chunk with a parameter, depending on which site the user actually is.
I have four resources container with the pagetitles home, user, jobs and system! They are accessible under https://localhost/modx/home/ etc.
And now i like to have a quickstart-div, with a different content, depending on the resources container. When a user opens https://localhost/modx/home/ the input-field in the quickstart div should be named "homesearch" and so on with the other resources.
My snippet:
$site = '[[*pagetitle]]';
$site = @trim($site);
switch ($site)
{
case 'home':
$output = $modx->getChunk('ch_quickstart', array('name' => 'homesearch'));
break;
case 'jobs':
$output = $modx->getChunk('ch_quickstart', array('name' => 'jobid'));
break;
case 'user':
$output = $modx->getChunk('ch_quickstart', array('name' => 'usernr'));
break;
case 'system':
$output = $modx->getChunk('ch_quickstart', array('name' => 'sysid'));
break;
default:
$output = "";
}
return $output;
und a chunk, named "ch_quickstart":
<div id="quickstart">Quickstart: <input type="text" name="[[+name]]" /></div>
But when i call the snippet in the template, the problem is, that the switch doesn't work! It always returns nothing. And i also tried back-tics but they also don't work...
Anybody got an idea, what's wrong? Or is this simply the wrong way, to realize such a feature in modx?
Thank you in advance!