We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8425
    • 159 Posts
    Hello,
    I need to be able to change document template dynamically. I know I could use CSS controled template but it wouldn't really work in my case.
    Let say I have a url like www.test.com?tpl=16.
    I want to set the template of the document to 16.
    Would the following work:
    - Create a plugin as below and select the event OnLoadWebDocument and OnLoadWebPageCache
    $tpl =  $_GET['tpl'];
    $modx->resource->set('template',$tpl); 

    Thanks for your help. [ed. note: eclipseTalk last edited this post 12 years, 2 months ago.]
      • 3749
      • 24,544 Posts
      I think that might work, though I'd be tempted to move the appropriate template code into Tpl chunks and use a snippet to pull in the desired chunks.


      ---------------------------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
      MODX info for everyone: http://bobsguides.com/modx.html
        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
        • 8425
        • 159 Posts
        Thanks Bob