We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32241
    • 1,495 Posts
    Hi guys, I just did this simple modification of the core code to have the document manager to display the parent template if they have one. So all the child document under certain folder will have the default selected template to the parent folder’s template.

    Hope it might be usefull to some of you, and finally get added to the core distribution file. laugh

    Somebody already built a better plugin to do this.
    http://modxcms.com/forums/index.php/topic,1092.0.html




    Look at line 543 on "manager/actions/dynamic/mutate_content.dynamic.action.php". Replace the whole code inside <?PHP ?> tag with this code.
    			<?php
    			if(isset($_REQUEST['pid'])) $parentTemplate = $modx->getPageInfo($_REQUEST['pid'], 1, 'template');
    			while ($row = mysql_fetch_assoc($rs)) {
    				if(isset($_REQUEST['newtemplate'])){
    					$selectedtext = $row['id']==$_REQUEST['newtemplate'] ? "selected='selected'" : "" ;
    				}
    				else if(isset($content['template'])) {
    					$selectedtext = $row['id']==$content['template'] ? "selected='selected'" : "" ;
    				}
    				else if(isset($parentTemplate) && $parentTemplate) {
    					$selectedtext = $row['id']==$parentTemplate['template'] ? "selected='selected'" : "" ;
    				}
    				else {
    					$selectedtext = $row['id']==$default_template ? "selected='selected'" : "" ;	
    				}
    			?>
    


    Hope it might be usefull to some of you.

    Note: I changed the code, before I use the wrong API getParent instead of getPageInfo

    Regards,
      Wendy Novianto
      [font=Verdana]PT DJAMOER Technology Media
      [font=Verdana]Xituz Media
    • I believe Mark has a plugin that does exactly this, btw, so no core hack is needed... it’d be interesting to see his version of that here. Good stuff regardless. smiley

        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 7455
        • 2,204 Posts
        Its nice to have modules made left and right but when do we get an repository to find them?
        and could some stander most used modules/plugins/snippets be shipped with the next release?

        i use the png plugin on every site I make now i need to intall it by hand all the time and the .... sorry drifting of here its off topic.

        Dimmy
          follow me on twitter: @dimmy01
          • 18397
          • 3,250 Posts
          FYI: I did not write the code--- I just told Ryan about it!
            • 32241
            • 1,495 Posts
            Hey, would like to know the plugin to do that too. I tried it, but I couldn’t figure out a way to access outside bariable from plugin. If there is a code for example, than I might start to get rid of this bad habit in hacking the code, everytime I need to accomplish something.

            Thanks
              Wendy Novianto
              [font=Verdana]PT DJAMOER Technology Media
              [font=Verdana]Xituz Media
              • 32241
              • 1,495 Posts
              I found it
              http://modxcms.com/forums/index.php/topic,1092.0.html

              Thanks netnoise, now that explains the global variables thing. Man, I never get use to those global variable thing in PHP. It’s SO CONFUSING, lol.

              Anyway, forget about the hack!
                Wendy Novianto
                [font=Verdana]PT DJAMOER Technology Media
                [font=Verdana]Xituz Media
              • FYI, I committed the plugin to add this to the next revision. smiley
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me