We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4172
    • 5,888 Posts
    Ok, thats realy very coool!
    But is there a way to use it with my own placeholders.
    Here the example from Ditto:
    $phx = new prePHx($template);
    $phx->setPlaceholders($placeholders);
    $output = $phx->output();
      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
      • 25663 MODX Staff
      • 12,272 Posts
      I think they’re just now input and output filters. smiley
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 7231
        • 4,205 Posts
        Quote from: rthrash at Dec 06, 2008, 09:05 AM

        I think they’re just now input and output filters. smiley
        Input? How can we apply this to input?
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don't know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: dev_cw at Dec 06, 2008, 10:01 AM

          Quote from: rthrash at Dec 06, 2008, 09:05 AM

          I think they’re just now input and output filters. smiley
          Input? How can we apply this to input?
          Input as in the source code and properties being used on an element.  You are running a filter process first on those, which prepares the output filtering to occur when the output is returned from the element.  So input filters apply to the source content and properties, while output filters act on the output returned from the element (or other data collected/created during input filtering).
            • 27330
            • 884 Posts
            Quote from: splittingred at Dec 05, 2008, 09:02 AM

            Ditto 2.1.2-alpha2 has been uploaded to the Web Transport Facility and is now accessible from your MODx install’s Package Management section.

            any reason why Ditto 2.1.2-Alpha1 is still available?
            Navigation>>Ditto>>Ditto 2.1.2-alpha2
            Bloggin>>Ditto>>Ditto 2.1.2-alpha1
              • 4172
              • 5,888 Posts
              With my new knowledge about parsing chunks in revolution from http://modxcms.com/forums/index.php/topic,31214.0.html I made a quick fix in Ditto for using the new included PHx-processing of revolution:
              In ditto.class.php:
              <?php
              	function render($resource, $template, $removeChunk,$dateSource,$dateFormat,$ph=array(),$phx=0,$x=0) {
                  	if (!is_array($resource)) {
              			return $this->modx->lexicon('resource_array_error');
              		}
              		$placeholders = array();
              		$contentVars = array();
              		foreach ($resource as $name=>$value) {
              			$placeholders["$name"] = $value;
              			//$contentVars["[[*$name]]"] = $value;
              		}
              
              		/* set author placeholder */
              		if (in_array("author",$this->fields["display"]["custom"])) {
              			$placeholders['author'] = $this->getAuthor($resource['createdby']);
              		}
              
              		/* set title placeholder */
              		if (in_array("title",$this->fields["display"]["custom"])) {
              			$placeholders['title'] = $resource['pagetitle'];
              		}
              
              		/* set sequence placeholder */
              		if (in_array("ditto_iteration",$this->fields["display"]["custom"])) {
              			$placeholders['ditto_iteration'] = $x;
              		}
              
              		/* set url placeholder */
              		if (in_array("url",$this->fields["display"]["custom"])) {
              			$placeholders['url'] = $this->modx->makeUrl($resource['id'],'','','full');
              		}
              
              		if (in_array("date",$this->fields["display"]["custom"])) {
              			$timestamp = ($resource[$dateSource] != "0") ? $resource[$dateSource] : $resource["createdon"];
              			$placeholders['date'] = strftime($dateFormat,$timestamp);
              		}
              
              		if (in_array("content",$this->fields["display"]["db"]) && $this->format != "html") {
              			$resource['content'] = $this->relToAbs($resource['content'], $this->modx->config['site_url']);
              		}
              
              		if (in_array("introtext",$this->fields["display"]["db"]) && $this->format != "html") {
              			$resource['introtext'] = $this->relToAbs($resource['introtext'], $this->modx->config['site_url']);
              		}
              
              		$customPlaceholders = $ph;
              		/* set custom placeholder */
              		foreach ($ph as $name=>$value) {
              			if ($name != "*") {
              				$placeholders[$name] = call_user_func($value[1],$resource, $this);
              				unset($customPlaceholders[$name]);
              			}
              		}
              
              		foreach ($customPlaceholders as $name=>$value) {
              			$placeholders = call_user_func($value,$placeholders);
              		}
              
              		if (count($this->fields["display"]['qe']) > 0) {
              			$placeholders = $this->renderQELinks($this->template->fields['qe'],$resource,$this->modx->lexicon('edit').' : '.$resource['pagetitle'].' : ',$placeholders);
              				/* set QE Placeholders */
              		}
              
                      //print_r($placeholders);
                      /*
              		if ($phx == 1) {
              			$PHs = $placeholders;
              			foreach($PHs as $key=>$output) {
              				$placeholders[$key] = str_replace( array_keys( $contentVars ), array_values( $contentVars ), $output );
              			}
              			unset($PHs);
              			$phx = new prePHx($template);
              			$phx->setPlaceholders($placeholders);
              			$output = $phx->output();
              		} else {
              		 	$output = $this->template->replace($placeholders,$template);
              			$output = $this->template->replace($contentVars,$output);
              		}
              		*/
              
              		 	$output = $this->template->replace($placeholders,$template);
              			//$output = $this->template->replace($contentVars,$output);		
              		
                      //I think here is something Todo:
              		if ($removeChunk) {
              			foreach ($removeChunk as $chunk) {
              				$output = str_replace('[[$'.$chunk.']]',"",$output);
              				$output = str_replace($this->modx->getChunk($chunk),"",$output);
              					/* remove chunk that is not wanted */
              			}
              		}
              		return $output;
              	}
              ?>


              in template.class.php:

              <?php
                  function replace( $placeholders, $tpl ) {
              /*
              		$keys = array();
              		$values = array();
              		foreach ($placeholders as $key=>$value) {
              			$keys[] = '[[+'.$key.']]';
              			$values[] = $value;
              		}
              		return str_replace($keys,$values,$tpl);
              */
                      $chunk = $this->modx->newObject('modChunk');
                      $chunk->setCacheable(false);
                      $output = $chunk->process($placeholders, $tpl);
                      return $output;
               
              	}
              
              	function fetch($tpl){
              
              		$template = "";
              		//if ($this->modx->getChunk($tpl) != "") {
              		//	$template = $this->modx->getChunk($tpl);
              		if ($chunk= $this->modx->getObject('modChunk', array ('name' => $tpl), true)) {
              			$template = $chunk->getContent();			
              		} else if(substr($tpl, 0, 6) == "@FILE:") {
              			$template = $this->get_file_contents(substr($tpl, 6));
              		} else if(substr($tpl, 0, 6) == "@CODE:") {
              			$template = substr($tpl, 6);
              		} else if(substr($tpl, 0, 5) == "@FILE") {
              			$template = $this->get_file_contents(trim(substr($tpl, 5)));
              		} else if(substr($tpl, 0, 5) == "@CODE") {
              			$template = trim(substr($tpl, 5));
              		} else {
              			$template = $this->modx->lexicon('missing_placeholders_tpl');
              		}
              		return $template;
              	}
              ?<


              Is that now the way we can do this things?

              Bruno
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 25663 MODX Staff
                • 12,272 Posts
                Hi Bruno17,

                Could you submit this as a patch in Jira please? Thanks!
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                  • 4172
                  • 5,888 Posts
                  Quote from: rthrash at Dec 09, 2008, 05:22 AM

                  Hi Bruno17,

                  Could you submit this as a patch in Jira please? Thanks!

                  Have it done here:http://svn.modxcms.com/jira/browse/DITTO-7
                  is it the right place to do it?
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 28215
                    • 4,149 Posts
                    Yes, it is. Thanks Bruno!
                      shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com