We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18397
    • 3,250 Posts
    Yes, you need to be a member of the testing team as it is in internal testing right now.
      • 5074
      • 5 Posts
      Your buildURL code doesn’t work well on my site.
      and my code needs urlencode( and "&">"&") for tag data.

      (function buildURL : current)
      				$url = $this->buildURL("tags=$tag",$tagDocID);
      


      (function buildURL : changed})
      			$encodedTag = urlencode($tag);
      				$url = $this->buildURL("tags=$encodedTag",$tagDocID);
      


      (function paginate)
      		if( $this->tags != "" )	/* CHIKAZAKI */
      			$tagUrl = "&tags=".urlencode($this->tags);	/* CHIKAZAKI */
      		else	/* CHIKAZAKI */
      			$tagUrl = "";	/* CHIKAZAKI */
      
        • 18397
        • 3,250 Posts
        "Your buildURL code doesn’t work well on my site."

        What specific issue are you encountering?
          • 16885
          • 255 Posts
          Quote from: Mark at Jan 12, 2007, 01:07 AM

          "Your buildURL code doesn’t work well on my site."

          What specific issue are you encountering?

          I suppose he’s using XHTML with application/xhtml+xml headers - those won’t like &’s instead of &’s
            • 18397
            • 3,250 Posts
            But makeURL changes all &’s to &’s before returning the output...
              • 21056
              • 327 Posts
              I had a need to filter by date but down to a day level, not just a month level as accommodated in the Ditto code. I amended the snippet itself as follows:

              // ---------------------------------------------------
              // Date Filter Parameters
              // ---------------------------------------------------
              
              if (!empty($_GET['year'.$dittoDisplayID])) {
              	if (!empty($_GET['month'.$dittoDisplayID])) {
              		$month = $_GET['month'.$dittoDisplayID];
              		$year = $_GET['year'.$dittoDisplayID];
              
              // Changedto support days
              if (!(empty($_GET['day'.$dittoDisplayID])) ){
               $modx->setPlaceholder("day$dittoDisplayID",$_GET['day'.$dittoDisplayID]);
               $day= $_GET['day'.$dittoDisplayID];
               $filterStr = "$year-$month-$day";
              } else {
               $day = '';
              $filterStr = "$year-$month";
              }
              $dateFilter = "$dateSource,$filterStr,date";
              		$modx->setPlaceholder("month$dittoDisplayID",$_GET['month'.$dittoDisplayID]);
              		$modx->setPlaceholder("year$dittoDisplayID",$_GET['year'.$dittoDisplayID]);
              	} else {
              		$year = $_GET['year'.$dittoDisplayID];
              		$dateFilter = "$dateSource,$year,date";
              		$modx->setPlaceholder("year$dittoDisplayID",$_GET['year'.$dittoDisplayID]);		
              	}
              	$filter= ($filter !==false) ? $filter."|$dateFilter": "$dateFilter";
              }
              
              


              And filter.class.inc.php (date switch):

              case "date" :
              				
              					$parts = explode('-', $this->filterValue);
              				
              					if (count($parts) == 1) { // Year only e.g. 2007
              						$min = mktime(0,0,0,1,1,$this->filterValue);
              						$max = mktime(23,59,59,12,31,$this->filterValue);
              					} else if (count($parts) == 2) { // Year and month e.g. 2007-01
              						$min = mktime(0,0,0,$parts[1], 1, $parts[0]);
              						$max = mktime(23,59,59,$parts[1], date("t", $min), $parts[0]);
              					} else if (count($parts) == 3) { // Year month and day e.g. 2007-01-11
              						$min = mktime(0,0,0,$parts[1], $parts[2], $parts[0]);
              						$max = mktime(23,59,59,$parts[1], $parts[2], $parts[0]);
              					}
              									
              					if ($value[$this->array_key] <= $min || $value[$this->array_key] >= $max)
              						$unset = 0;
              					break;


              It now passes the date to the filter in the format yyyy-mm-dd (month and date are both optional).

              Hope this might be something you could incorporate into the version.
                Author: ManagerManager plugin - customise your ModX manager interface

                Rckt - web development, Sheffield, UK
                • 1932
                • 137 Posts
                Ditto rules, thanks guys!

                In my post summaries, I wanted to remove both the formatted pub_date which I have as a chunk on top of my blog post pages and the comments chunk at the bottom. Currently, only one chunk can be excluded by using the &removeChunk=`chunkname` parameter, I wanted to extend this to allow for a comma separated list of chunks to be excluded. The same effect could be achieved using a custom template, but I can certainly think of cases where this wold be an inconvenience.

                My code modifications are as follows:

                In the Ditto 1.1b2 snippet code, change line 147 from:
                $removeChunk = isset($removeChunk)? '{{'.$removeChunk.'}}' : '';
                	// chunk to be stripped from content

                to:
                $removeChunk = isset($removeChunk)? $removeChunk : '';
                	// comma separated list of chunks to be stripped from content
                

                Now edit truncate.class.inc.php in assets/snippets/ditto/classes and change line 199 from:
                		$summary = str_replace($commentschunk, "", $summary);

                to:
                		foreach (explode(',', $commentschunk) as $chunk) $summary = str_replace("{{" . $chunk . "}}", "", $summary);



                Is there any reason for limiting it to just one chunk? Can we use PHx to determine whether content is being displayed directly or loaded through another snippet?
                  • 5074
                  • 5 Posts
                  please forget about "&amp;"-things.
                  I mean "MY" code needs "&" >> "&amp;"
                  ok ?

                  new "buildURL " code (which you posted) doens’t return proper HTML;

                  ie.
                  when tagging via URL, ditto(even after changed buildURL) returns "startID=6" not "startID=6&amp;tags=XXXX"

                  sorry for my poor English.
                    • 18397
                    • 3,250 Posts
                    Try this function:

                    	function buildURL($args,$id=false) {
                    		global $modx, $dittoID;
                    			$query = $_GET;
                    			unset($query["id"]);
                    			unset($query["q"]);
                    			$args = explode("&",$args);
                    			foreach ($args as $arg) {
                    				$arg = explode("=",$arg);
                    				$query[$dittoID.$arg[0]] = $arg[1];
                    			}
                    			$queryString = "";
                    			foreach ($query as $param=>$value) {
                    				$queryString .= '&'.$param.'='.$value;
                    			}
                    			$cID = ($id !== false) ? $id : $modx->documentObject['id'];
                    			$url = substr($modx->config['site_url'], 0, -1).$modx->makeURL($cID, '', $queryString);	
                    			return $url;
                    	}
                    
                      • 1932
                      • 137 Posts
                      Bug when using &documents,

                      Please see my post here: http://modxcms.com/forums/index.php/topic,9489.msg74594.html#msg74594