We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17016
    • 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
      • 17016
      • 138 Posts
      Is there maybe an other way than the getObject/get-technique to realize this?
        • 3749
        • 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>
        

          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting