Perfect - THANKS A MILLION
Of the 3 solutions which all work PERFECT which would you suggest in terms of performance overhead and page load times?
<?php
//[[!templateSwitcher? &newslisting=`3,24,35,38,42,44,47,32` &bloglisting=`54,64,75` &contact=`56` &default=`textContent`]]
$id = $modx->resource->get('id');
unset($scriptProperties['default']);
foreach ($scriptProperties as $file => $ids) {
$ids = explode(',', $ids);
if (in_array($id, $ids)) {
$params['file'] = 'assets/templates/inc/' . $file . '.php';
return $modx->runSnippet('include', $params);
}
}
$params['file'] = 'assets/templates/inc/' . $default . '.php';
return $modx->runSnippet('include', $params);
with
[[!templateSwitcher? &newslisting=`3,24,35,38,42,44,47,32` &bloglisting=`54,64,75` &contact=`56` &default=`textContent`]]
or the second snippet
<?php
//id get the current resource
$id = $modx->resource->get('id');
switch ($id) {
case 3:
case 24:
case 35:
case 38:
case 42:
case 44:
case 47:
case 32:
$res = 'newslisting';
break;
case 54:
case 64:
case 75:
$res = 'bloglisting';
break;
case 56:
$res = 'contact';
break;
default:
$res = 'textContent';
}
if ($res) include $modx->getOption('assets_path').'templates/inc/'.$res.'.php';
return;
with:
I really appreciate the effort you put into these guys!
Thanks
PS this worked too by the way for people following the thread.
<?php
$resource = $modx->resource->get('id'); //modified from above
if ($resource == '3' || $resource == '24' || $resource == '35' || $resource == '38' || $resource == '42' || $resource == '44' || $resource == '47' || $resource == '32'){
echo "[[!include? &file==`assets/templates/inc/newslisting.php]]";
}
else if ($resource == '54' || $resource == '64' || $resource == '75'){
echo "[[!include?&file==`assets/templates/inc/bloglisting.php]]";
}
else if ($resource == '56'){
echo "[[!include?&file==`assets/templates/inc/contact.php]]";
}
else{
echo "[[!include?&file==`assets/templates/inc/textContent.php]]";
}
[ed. note: howster last edited this post 12 years, 5 months ago.]