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
    Sorry, it’s kinda off-topic to the current conversation.

    Anyway, I found a bug in @INHERIT binding and getTemplateVarsOutput API. As far as I know, it only affect Newslisting snippet.
    Here is the problem.

    I create a TV called block_inherit. I set the default value to @INHERIT.
    Now I create this kind of folder format.
    parent
    |- subfolder1
        |- document1
        |- document2
        |- document3
    

    If I called newslisting snippet in subfolder1 to display its own subdocuments, then it will works just fine. Now if I called newslisting snippet in parent document and pass startID parameter to display subfolder1 children, it will display a different TV output, because the @INHERIT is being calculated from parent folder id, instead of subfolder1 id.

    The problem is being caused by the ProcessTVCommand function. When newslisting snippet is calling getTemplateVarOutput API, it will basically called the ProcessTVCommand without passing the requested document id. Inside the ProcessTVCommand, the @INHERIT binding always assume that the incoming request will always be from the current document id, while it’s not correct when ProcessTVCommand is being used by the getTemplateVarOutput API outside the current document id.

    There are several ways to fix this. What I’m gonne present in here will be using a global variables, which in my opinion, it’s not a clean solution. Another way to do it, is to change each getTVDisplayFormat and ProcessTVCommand function an extra parameter called $docid.

    Here is the fix with the first solution.

    In document document.parser.class.inc.php, look for getTemplateVarOutput function and change it with this.
    	# returns an associative array containing TV rendered output values. $idnames - can be an id or name that belongs the template that the current document is using
    	function getTemplateVarOutput($idnames=array(), $docid="", $published=1) {
    		if(count($idnames)==0) {
    			return false;
    		}
    		else {
    			$output = array();
    			$result = $this->getTemplateVars(($idnames=='*' || is_array($idnames)) ? $idnames:array($idnames),"*",$docid,$published,"",""); // remove sort for speed
    			if ($result==false) return false;
    			else {
    				$baspath = $this->config["base_path"]."manager/includes";
    				include_once $baspath."/tmplvars.format.inc.php";
    				include_once $baspath."/tmplvars.commands.inc.php";
    				for($i=0;$i<count($result);$i++) {
    					$row = $result[$i];
    					// to-do needs fixing when getting tvs from other pages
    					$replace_richtext = "";
    					$richtexteditor = "";
    					$w = "100%";
    					$h = "300";
    					// BEGIN - FIXED @INHERIT binding to inherit from the given doc id, instead of current doc id
    					// Modified by Wendy Novianto
    					$GLOBALS['fixed_inherit_docid'] = $docid;
    					$output[$row['name']] = getTVDisplayFormat($row['name'],$row['value'],$row['display'],$row['display_params'],$row['type']);
    					unset($GLOBALS['fixed_inherit_docid']);
    					// ENDED - FIXED @INHERIT
    				}
    				return $output;
    			}
    		}
    	}
    


    In document tmplvars.commands.inc.php, look for case "@INHERIT".
    			case "@INHERIT":
    			
    				$output = $param; // Default to param value if no content from parents
    				// BEGIN - FIXED @INHERIT binding to inherit from the given doc id, instead of current doc id
    				// Modified by Wendy Novianto
    				if(!isset($GLOBALS['fixed_inherit_docid']) || !is_numeric($GLOBALS['fixed_inherit_docid']))
    					$GLOBALS['fixed_inherit_docid'] = $modx->documentIdentifier;
    				$doc = $modx->getDocument($GLOBALS['fixed_inherit_docid'],'id,parent');
    				// ENDED - FIXED @INHERIT
    				
    				while($doc['parent'] != 0) {
    					
    					$parent_id = $doc['parent'];
    					
    					if($doc = $modx->getDocument($parent_id, 'id,parent')) {
    						
    						$tv = $modx->getTemplateVar($name, '*', $doc['id']);
    						if($tv['value'] && substr($tv['value'],0,1) != '@') {
    							$output = $tv['value'];
    							break 2;
    						}
    						
    					} else {
    			
    						// Get unpublished document
    						$doc = $modx->getDocument($parent_id, 'id,parent',0);
    						
    					}
    					
    				}
    				break;
    


    That’s all.
    Hope it will be fixed in 0.9.2 release.

    Take care...

    ADDED: Bug tracker: http://modxcms.com/bugs/task/337
      Wendy Novianto
      [font=Verdana]PT DJAMOER Technology Media
      [font=Verdana]Xituz Media
      • 32241
      • 1,495 Posts
      Fix the code above.
        Wendy Novianto
        [font=Verdana]PT DJAMOER Technology Media
        [font=Verdana]Xituz Media
        • 4018
        • 1,131 Posts
        In other news...I’m having loads of fun with the latest 2.0.5.1 version of TinyMCE. I was having loads of trouble getting it to load. Seems they added something to the source that caused it to not load. I think I figured it out though. Once I get it all worked up with the language selection in place then I’ll up it to the trunk and make it the default editor instead of FCKEditor. FCKEditor will still be a part of the distro but won’t be selected by default.

        As far as language selection goes, I’m implementing it in two ways. First, the default language of the editor will be based on the selected language in the manager itself. This made the most sense to me since the language setting of the manager is global and not a per-user setting. For front-end use, I’m thinking of adding a global setting under the system configuration settings for the language preference on the front-end. I’m thinking of calling it Editor Language or the like. Instead of implementing a language dropdown for each RTE, it would make a whole lot more sense to have just one setting for all the RTE’s. The advantage of this is that the manager could be set for one language while your front-end RTE’s could be set for another. Fairly easy to implement in the long-run. smiley

        Also, I received an e-mail regarding the implementation of XStandard as an RTE. At the moment, I simply have too much on my plate to work on that. Plus, judging by the code samples I’ve looked at, getting XStandard to work right is a rather tricky proposition. It’s gonna take time to implement it. Once I’ve knocked out the tasks I’ve delegated to myself, I’ll find more time to play with it. But for now...it’s business at hand! smiley
          Jeff Whitfield

          "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
          • 32241
          • 1,495 Posts
          That sounds like a really good idea to me.

          Give it a go Jeff wink
            Wendy Novianto
            [font=Verdana]PT DJAMOER Technology Media
            [font=Verdana]Xituz Media
            • 25663 MODX Staff
            • 12,272 Posts
            Jason’s got a hankerin’ to rip out the atrocious current statistics as it bogs down the database and is actually causing performance issues and db timeouts.

            I’ve got a notion that SlimStats would be a good option. Go clickety-click around on Pixelhick then jump on over to the stats view page to see if you agree.
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Ryan! I’m too old to be able to take that kind of shock! That second link dumped me off on this page: http://www.microsoft.com/ because the url is malformed!

              And you probably already know about this:

              Warning: ob_start() [ref.outcontrol]: output handler ’ob_gzhandler’ conflicts with ’zlib output compression’ in /home/httpd/vhosts/pixelhick.com/httpdocs/assets/plugins/slimstats/index.php on line 27
                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
                • 25663 MODX Staff
                • 12,272 Posts
                LOL! Sorry Susan. I got it fixed on the site and on the link.
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                  • 33337
                  • 3,975 Posts
                  Slimstat package looks pretty nice!

                  I hope we also password-protect the stats page ? no ? (would be good wink)
                    Zaigham R - MODX Professional | Skype | Email | Twitter

                    Digging the interwebs for #MODX gems and bringing it to you. modx.link
                    • 6726
                    • 7,075 Posts
                    Quote from: zi at Apr 08, 2006, 11:43 PM
                    Slimstat package looks pretty nice! I hope we also password-protect the stats page ? no ? (would be good wink)

                    The way I intended to do that quick and dirty is using a .htpassword file, but if there is a better way...
                      .: COO - Commerce Guys - Community Driven Innovation :.


                      MODx est l&#39;outil id
                      • 25663 MODX Staff
                      • 12,272 Posts
                      I’ve now got SlimStats replacing the current Stats page in the manager. Styling is aweful, and I need to fix how the links are built (lovely frames... :/ ) but it shouldn’t be so bad.
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me