We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11975
    • 2,542 Posts
    Here is the error message.


    Fatal error: Call to a member function on a non-object in /Users/fredm/Sites/test/manager/includes/document.parser.class.inc.php(748) : eval()’d code on line 212

    Ditto Snippet line 212:

    if ($debug) {
    	$output .= $ditto->debug->header($ditto->fields,$documentIDs,$ditto_version, $summarize, $count, $sortBy, $sortDir, $start, $stop, $total,$filter,$ditto->advSort);
    }


    It seems that among all the changes I had made, this one is enough

    Changed line 111
    if ($debug) {
    


    to

    if ($debug ==1 ) {
    


    :-)
      Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
      • 11975
      • 2,542 Posts
      One more thing Mark,

      could you please change the line 17

      $ditto_base =  "assets/snippets/ditto/";
      


      to

      $ditto_base = $modx->config['base_path'] . "assets/snippets/ditto/";
      


      When I’m trying to call ditto with modx->runSnippet API function, ditto returns this error.


      Language file does not exist

      Changing the line make it disappears.

      Thx.

      :-)
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 18397
        • 3,250 Posts
        Thanks heliotrope. Changes have been made. Has anyone tried the new debug mode?
          • 11975
          • 2,542 Posts
          Hi Mark,

          Still testing ditto with about ~2 400 documents.

          If I’m setting the depth param to a value > to 1 (3 for instance) in order to browse my whole tree


          Fatal error: Maximum execution time of 30 seconds exceeded in /Users/fredm/Sites/test/manager/includes/document.parser.class.inc.php on line 1252


          This part of the code seems to be involved in this issue,
          retrieve all the parents and childIds takes too much time.

          $documentIDs = $ditto->determineIDs( ..... );
          



          :-)
            Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
            • 11975
            • 2,542 Posts
            I guess I’ve found a bug with &tagData param and parseCustomPlaceholders function in ditto class.

            Sample call

            [[ditto? &startID=`0` &tagData=`name_tv1,name_tv2` ... ]]

            returns an sql error

            « Execution of a query to the database failed - Unknown column ’sc.name_tv1’ in ’field list’ »

            I have investigated a bit and printed out $ditto->fieds


            Array
            (
            [display] => Array
            (
            [db] => Array
            (
            [0 ] => id
            [1] => tagsPhoto,typeRecette
            [2] => published
            [4] => pagetitle
            )

            [tv] => Array
            (
            [0 ] => thumbImg
            [1] => typeRecette
            [2] => tagsPhoto
            )


            )

            [backend] => Array
            (
            [tv] => Array
            (
            )

            [db] => Array
            (
            [0 ] => id
            [1] => published
            [2] => tagsPhoto,typeRecette
            )

            )

            )



            :-)


            Quick and dirty fix

            // ---------------------------------------------------
            	// Parse the required fields out of the custom placeholders
            	// ---------------------------------------------------
            	
            	function parseCustomPlaceholders($placeholders) {
            	
            		foreach ($placeholders as $name=>$value) {
            		
            			if(is_array($value[0])) {
            			
            				if ($value[0][1] != "*") {
            				
            					$this->appendField($value[0][0],$value[0][1]);					
            				
            				} else {
            				//added these lines
            				$tstring = $value[0][0];
            					if(strpos($tstring,",")!==false){
            						$n = explode(",",$tstring);
            						foreach($n as $idtv){
            						$this->appendField($idtv,"backend");
            						$this->appendField($idtv,"display");
            						}
            					}else{
            			//end changes		
            					$this->appendField($value[0][0],"backend");
            					$this->appendField($value[0][0],"display");
            					}
            				}					
            			} else if(is_array($value)) {
            			
            				$this->appendField($value[0],"display");
            			}
            		}
            	}
            
            



            $ditto->fields with the fix


            Array
            (
            [display] => Array
            (
            [db] => Array
            (
            [0 ] => id
            [1] => published
            [3] => pagetitle
            )

            [tv] => Array
            (
            [0 ] => thumbImg
            [1] => typeRecette
            [2] => tagsPhoto
            )

            [custom] => Array
            (
            [0] => title
            )

            [item] => Array
            (
            )

            [qe] => Array
            (
            )

            [phx] => Array
            (
            )

            [rss] => Array
            (
            )

            [json] => Array
            (
            )

            [xml] => Array
            (
            )

            [unknown] => Array
            (
            )

            )

            [backend] => Array
            (
            [tv] => Array
            (
            [0 ] => tagsPhoto
            [1] => typeRecette
            )

            [db] => Array
            (
            [0 ] => id
            [1] => published
            )

            )

            )
              Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Doesn’t seem to be responding to sortBy. I’m trying to get it to sort by menuindex, but it’s not cooperating.
                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
                • 11975
                • 2,542 Posts
                Hi mark,

                I’ve made some changes to ditto to improve performance.

                Some functions were slowing down ditto when it handles several thousands of documents .
                I’ve changed the way ditto get the data from db and how the parents are found.

                For instance with these changes with 2 400 docs in my db, retrieving all the documents(with 3 tvs) requires only 14 request and no more 4 000.
                I will post my changes later today.
                I have tried to be as close as I could from the original code.


                :-)
                  Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                  • 6726
                  • 7,075 Posts
                  Pretty impressive gain here !

                  It would open new doors for MODx for projects with a lot of documents...
                    .: COO - Commerce Guys - Community Driven Innovation :.


                    MODx est l'outil id
                    • 11975
                    • 2,542 Posts
                    code needs more testing as I don’t know how it affects other ditto functions.

                    I’ve rewritten the getParendsIds function the GetDocuments function and the appendTV function.
                    before changes there was a request per document to get TV value.
                    Now only one per TV for all the documents.

                    :-)
                      Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                      • 11975
                      • 2,542 Posts
                      Hi all,

                      here are some results with 2252 docs in DB

                      With a call to get all documents

                      MySQL: 0.2873 s, 11 request(s), PHP: 3.2016 s, total: 3.4889 s, document retrieved from database.

                      I will update a demo site in the afternoon with the new script.
                      That way you will see by yourself grin

                      :-)
                        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l