We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26982
    • 75 Posts
    I have a container using template X, but I would like all pages within that container to default to template Y. Is that possible?
    (background: my container is "blog" and all the pages within it are blog articles, but I have a different template for the blog summary and detail pages)

    Thanks,

    /\dam
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The easiest way would be to put your blog pages under another document that is unpublished, and have it use the blog page template and its children will inherit it if you’re using the Inherit Template plugin.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 25969
        • 118 Posts
        Just disable "Inherit Parent Template" under "Resources > Manager Resources > Plugins" and set "Default template" under "Tools > Configuration > Site" to "template Y".
          • 11975
          • 2,542 Posts
          Hi,

          If you wish to select which template to apply to the childs for each folder
          ’ve written a plugin for such case.

          => http://modxcms.com/forums/index.php/topic,21150.msg130700.html#msg130700

          Hope that helps.

          :-)
            Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
            • 7231
            • 4,205 Posts
            You can also hack the Inherit Parent Template plugin and add some logic to set the template to use for a defined container. I added an array to be able to set multiple containers at one time.

            <?php
            global $content;
            $e = &$modx->Event;
            $containers = array(1,2,3); // container IDs for custom template
            $custom_tpl = 12; //custom template ID
            
            switch($e->name) {
              case 'OnDocFormPrerender':
                if(($_REQUEST['pid'] > 0) && ($id == 0)) {
                	if(in_array($_REQUEST['pid'], $containers)) { 
                		$content['template'] = $custom_tpl;
                	}
                  	elseif ($parent = $modx->getPageInfo($_REQUEST['pid'],0,'template')) {
                    	$content['template'] = $parent['template'];
                  	}
                }
                break;
            
              default:
                return;
                break;
            }
            ?>


            Not to fancy but works smiley
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 26982
              • 75 Posts
              Wow, thanks for all the varied solutions to this smiley.
              @sal : thanks, but I can’t set my site-wide default to template Y, as the blog is only a subsection of my site, and I’m already using a different template as my default one.

              heliotrope is today’s King of Answers though, as his plugin worked an absolute treat. The clear instructions meant I had it installed in only a few minutes, and even learned a bit more about MODx as a result. Sincere thanks!

              /\dam
                • 7231
                • 4,205 Posts
                Quote from: ganeshXL at Feb 07, 2008, 12:52 PM

                The easiest thing is to just create a new blog-entry by way of duplicating an existing doc. In the manager tree, do mouse-right-click and select "duplicate this page". The template should be the same as the source-doc, not its container.
                That works well for me. but my clients don’t like it. I have also created a "template’ document and added a link on the manager home to duplicate this document. this is also a good solution and works well for clients.

                This is a true MODx example, many ways to get it done and they are all right grin
                  [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                  Something is happening here, but you don&#39;t know what it is.
                  Do you, Mr. Jones? - [bob dylan]
                  • 26982
                  • 75 Posts
                  My clients don’t seem to like the concept of duplicating a page to make a new one either, although it makes perfect sense to me.
                  However, my personal problem with the "duplicate" solution on a live site is discussed here: Option when cloning documents to set the copy to "unpublished" automatically?

                  /\dam
                    • 25663 MODX Staff
                    • 12,272 Posts
                    Hello sheik, please file that request for not immediately publishing cloned docs in the bugtracker as a request. We should be able to get it into 0962. http://modxcms.com/bugs/
                      Ryan Thrash, MODX Co-Founder
                      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                      • 26982
                      • 75 Posts
                      Sorry, only just seen this - but it looks as if you’ve committed the changes now, many thanks!

                      /\