We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28554
    • 201 Posts
    Hi again smiley.

    So my own site is coming along nicely, but I know what I’m doing. I can only assume that my clients don’t, and that they won’t, for example, select the right template when adding a child to a page. Is there any way to force a template-type for new children of a certain page? So for example force all children of resource Blog to have "blogEntry" as template?

    Thanks!
      • 4172
      • 5,888 Posts
      didn’t test it but you can try to edit inherit-parent-template-plugin like that:

      /*
       * Written By Raymond Irving - 12 Oct 2006
       *
       * Simply results in new documents inherriting the template 
       * of their parent folder upon creating a new document
       *
       * Configuration:
       * check the OnDocFormPrerender event
       *
       * Version 1.0
       *
       */
      
      global $content;
      $e = &$modx->Event;
      $tvname='childTemplate';
      
      switch($e->name) {
        case 'OnDocFormPrerender':
          if(($_REQUEST['pid'] > 0) && ($id == 0)) {
            if($parent = $modx->getPageInfo($_REQUEST['pid'],0,'template')) {
                $tv=$modx->getTemplateVarOutput($tvname,$_REQUEST['pid']);
                $content['template'] = !empty($tv[$tvname])?$tv[$tvname]: $parent['template'];
            }
          }
          break;
      
        default:
          return;
          break;
      }


      have a TV in your parent resource named childTemplate which holds the templateID for its childs.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 28554
        • 201 Posts
        I’ve found a Plug-in called Inherit Selected Template. I’ve configed it exactly the way the manual told me and assigned a TV, but when I try to edit the container of which I want the children to be forced a template, the listbox gives me back this error:

        Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/digitaaldier.nl/public_html/manager/includes/tmplvars.commands.inc.php(60) : eval()'d code on line 1


        The EVAL in the TV is:

        @EVAL $sql = 'SELECT templatename,id FROM '.$modx->db->config'table_prefix'.'site_templates';$a=array(array('',''),array('Inherit Parent','-1')); $v = $modx->db->query($sql);while($rows = mysql_fetch_row($v)) $a=$rows; return $a;


        Any thoughts?
          • 4172
          • 5,888 Posts
          why not just:

          @SELECT templatename,id FROM `modx_site_templates`


            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 28554
            • 201 Posts
            Worked like a charm! Thanks alot guys smiley