-
- 138 Posts
I want to get two different processed outputs of a resource by running a snippet:
1. Resource processed by Template A
2. Resource processed by Template B
To realize it I was thinking about something like this for the resource with the id=1:
$mydocument = $modx->getObject(’modResource’, 1);
$pagevariable = $mydocument->get(’the_whole_page_processed_by_template17’);
or:
$currentdocument = $modx->resource->get(’document parsed by template 7’);
Does anybody know how I have do this correctly?
I tried to realize this by using the snippet getResources, too. But it didn´t work because I cannot use templates for rendering, but just chunks.
Does anybody have an idea how to make this work?
Letti
-
- 138 Posts
Is there maybe an other way than the getObject/get-technique to realize this?
-
- 24,544 Posts
I think what you want is big Tpl chunks rather than separate templates.
Put everything you want on both pages in the template and the page-specific output in the Tpl chunks. Then you can do something like this in the snippet:
<?php
$mydocument = $modx->getObject('modResource', 1);
$pagevariable = $modx->getChunk('chunk17', $myDocument->toArray() );
// or
$pagevariable = $modx->getChunk('chunk7', $myDocument->toArray() );
That will set all fields of the resource as placeholders, which you can put in the Tpl chunks to display the page info:
<p>[[+content]]</p>
<p>[[+description]]</p>
<p>[[+Tv1]]</p>