Hello,
I am trying to get and process resources from another table (same database scheme like modx_site_content) with a plugin:
if($modx->event->name != 'OnLoadWebDocument') return;
$obj = $modx->getObject('myTable', array('published' => 1, 'deleted' => 0, 'id' => $id ));
$oldid = $obj->get('id');
$obj = $modx->newObject('modDocument', $obj->toArray());
$obj->set('class_key', 'modDocument');
$obj->set('id', $oldid);
$modx->resource =& $obj;
It’s just creating a new resource object and sets it as $modx->resource, so that modx continues working with the new one.
The problem is that modx does not set any template variables for that new resource ([[*pagetitle]], chunks, snippets and so on are replaced though). I can get them in the plugin with
but there are not rendered automatically.
Why that?