We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5340
    • 1,624 Posts
    What do you mean on the frontend.

    Are you using it with QuickManager?
      • 3689
      • 264 Posts
      Quote from: cipa at Sep 19, 2009, 08:49 AM

      What do you mean on the frontend.

      Are you using it with QuickManager?

      I tried it with QM first couple of times
        • 5340
        • 1,624 Posts
        Template Rules works fine with QM. Do you still have problem with it?
          • 5689
          • 289 Posts
          cipa, I just want to say thanks for this excellent plugin! I just set it up with my church’s site, and it works great. It will add that much more eloquence to using the Manager.
            I'm learning more about MODx all the time and loving it.
            • 22897 ☆ A M B ☆
            • 209 Posts
            Anyone else having problems with this on Evo 1.0.1? It doesn’t like the grouping of the templates in optgroups - it’s not hiding/showing the correct items for me.

            Got the hang of it. For reference - if you only want the specified template to be the only template available in the drop down list, use the following
            5[]

            Where 5 is the template you want to be selected.
              MAPLEDESIGN MODX development and MODX web design and custom development. Proud to serve UK and International clients!
              • 5340
              • 1,624 Posts
              It should be 5[5].

              5 <- what template to select from the list
              [5] <- what template(s) to show in the list

              5[] works but I would not recommend using it. The code might change in the future.

              Thx
                • 19369
                • 1,098 Posts
                Hi, I have just discovered this plugin, it would be VERY useful in my websites.
                However, I can’t get it to work, when I enable the plugin managermanager and tinyMCE stop working, and I get this error:

                Fatal error: Call to undefined function TR_getTvValueAndLevel() in ..\manager\includes\document.parser.class.inc.php(746) : eval()'d code on line 53


                This is the line 746:
                        eval ($pluginCode);


                I have MODx Evolution 1.04
                  • 5340
                  • 1,624 Posts
                  Seems that you don’t have all the files in place. Or you forgot do define something.

                  Did you do this?

                  I. Extract all files from package and upload "templaterules" folder in the "assets/plugins" folder.

                    • 19369
                    • 1,098 Posts
                    Hi, I have installed the plugin again in a fresh installation of MODx Evolution 1.03 (Btw, I have Win XP and XAMPP), but I get the same error:

                    Fatal error: Call to undefined function TR_getTvValueAndLevel() in ..\manager\includes\document.parser.class.inc.php(746) : eval()'d code on line 53

                    ManagerManager and TinyMCE stop working, and if I open Elements > Manage Elements, I see this text on the bottom of the page:
                    \nDTJS;\n\n }else{ \n //NTD - no allowed templates functionality\n }\n \n \n }else{\n //NTD\n }\n \n return $jsOutput;\n\n}\n\n\n\n?>\n
                    '; var boxHtml = new MooPrompt('System Alert', sysAlert, { buttons: 1, button1: 'Ok', width: 500 }); }); // ]]> 
                      • 19369
                      • 1,098 Posts
                      Maybe this might be useful, is taken from Reports > System Events log
                      Template Rules - Plugin - System Events
                      Error
                      
                      Undefined index: pid
                      
                      db->config['table_prefix']."site_tmplvar_contentvalues WHERE tmplvarid = " . $templateRulesTvID . " AND contentid = " . $startId; $rs= $modx->dbQuery($sql); $row = $modx->fetchRow($rs); if($row && $row['value'] != ''){ //stop while loop $startId = 0; //save TV value $tplVal = $row['value']; }else{ //get next parent $sql = "SELECT parent FROM ".$modx->db->config['table_prefix']."site_content WHERE id = " . $startId; $rs= $modx->dbQuery($sql); $row = $modx->fetchRow($rs); $startId = $row['parent']; } } $retval = array("value"=>$tplVal, "level"=>$level); return $retval; } // gets the value of the default teplate. Used when a new document/resource is created function TR_getDefaultTemplate($tvValueAndLevel){ $tvValue = $tvValueAndLevel['value']; $level = $tvValueAndLevel['level']; $template = 'x'; //set template to the defaultTemplate value $aTplVals = explode(",",$tvValue); if(isset($aTplVals[$level-1])){ $defaultTemplateInfo = $aTplVals[$level-1]; $hasAllowed = strpos($defaultTemplateInfo, '['); if($hasAllowed){//parse allowed templates $aAllowedTemplatesTemp = explode("[",$defaultTemplateInfo); $template = intval($aAllowedTemplatesTemp[0]); }else{ //no allowed templates functionality $template = intval($defaultTemplateInfo); } }else{ //NTD } return $template; } //gets the js code for showing only configured templates function TR_getJsCode($tvValueAndLevel, $documentTemplateId = ''){ $tvValue = $tvValueAndLevel['value']; $level = $tvValueAndLevel['level']; $jsOutput = ''; $aTplVals = explode(",",$tvValue); if(isset($aTplVals[$level-1])){ $defaultTemplateInfo = $aTplVals[$level-1]; $hasAllowed = strpos($defaultTemplateInfo, '['); if($hasAllowed){//parse allowed templates $aAllowedTemplatesTemp = explode("[",$defaultTemplateInfo); //prepare list for javascript, add default id and switch | to , for javascript array compatibility if($documentTemplateId){ $allowedTemplatesList = '[' . $documentTemplateId . ',' . $aAllowedTemplatesTemp[0] . ',' . str_replace("|", ",", $aAllowedTemplatesTemp[1]); }else{ $allowedTemplatesList = '[' . $aAllowedTemplatesTemp[0] . ',' . str_replace("|", ",", $aAllowedTemplatesTemp[1]); } //javascript for hiding unwanted templates in drop down $jsOutput = << DTJS; }else{ //NTD - no allowed templates functionality } }else{ //NTD } return $jsOutput; } ?>