This question has been answered by bsehovac. See the first response.
You would need a plugin. Keep in mind that the content may or may not need to be parsed, if it has snippets or chunks or other MODx tags the raw content won't do you any good. You would also have to consider caching - is the resource normally to be cached or not.
Are you planning to use this as an AJAX result? If so, you can use JQuery's load() feature; it takes a second argument consisting of the HTML element, specified by an ID attribute, in the return whose content to use.
<?php if(!filter_has_var(INPUT_GET, 'templateid')){ return true; }else{ if (!filter_input(INPUT_GET, 'templateid', FILTER_VALIDATE_INT)){ return true; }else{ $templateId = $_GET['templateid']; if($templateId) { $modx->resource->cacheable = 0; $modx->resource->template = $templateId; } return true; } }
This should do the trick. Create a plugin and attach it to the OnLoadWebDocument event:
There's one disadvantage here though. Notice that I set cacheable=0 for this resource call. That is necessary, otherwise the resource will be cached with your alternate template and it will appear that way every time it's requested. That may slow things down a bit, depending on what's in the content. If the content is just text, it should still be plenty fast.
$alias = $_GET['alias']; $resource = $modx->getObject(modResource, array('alias' => $alias)); $pagetitle = $resource->get('pagetitle'); $content = $resource->get('content'); $introtext = $resource->get('introtext'); $output .= '<div id="pagetitle">'. $pagetitle .'</div>'; $output .= '<div id="introtext">'. $introtext .'</div>'; $output .= '<div id="content">'. $content .'</div>'; return $output;
return $modx->getChunk($chunk,$resource->toArray());