D
D
Dmitry Logvinenko2012-07-26 16:09:56
MODX
Dmitry Logvinenko, 2012-07-26 16:09:56

Ditto loses placeholders on output

Immediately an example from life.
There is MODx Evo, there is such a call to Ditto:

<section class="news">
  <header>
    <h1>{{resource-title}}</h1>
  </header>
  
</section>


Chunk ditto-news-item:
<article class="news-item">
  <header>
    [+news-image+]
    <date class="date">
      [+date+]
    </date>
    <h2>
      {{resource-title-tpl}}
    </h2>
  </header>
  {{if-intro-tpl}}
  {{if-readmore-tpl}}
  {{if-main-tpl}}
</article>


Chunk if-intro-tpl:
[+introtext:ne=``:then=`<section class="pre"><p>[+introtext+]</p></section>`:else=``+]


If we run this whole thing, then we won’t see the resource title and introtext on the page - only the surrounding markup will remain of them. But if you take the code from the last chunk and do something like this:
<article class="news-item">
  <header>
    [+news-image+]
    <date class="date">
      [+date+]
    </date>
    <h2>
      <!--{{resource-title-tpl}}--> [+longtitle:ne=``:then=`[+longtitle+]`:else=`[+pagetitle+]`+]
    </h2>
  </header>
  <!--{{if-intro-tpl}}-->[+introtext:ne=``:then=`<section class="pre"><p>[+introtext+]</p></section>`:else=``+]
  {{if-readmore-tpl}}
  {{if-main-tpl}}
</article>


the corresponding lines will be displayed. At the same time, as you can see, calling a chunk from another chunk is supported (HTML is inserted), only placeholders are lost

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Logvinenko, 2012-07-26
@dmlogv

Do not confuse, but it does not help, just like unchecking the caching resource. Just like clearing the MODx cache completely.

E
ertaquo, 2012-07-26
@ertaquo

As far as I remember, Ditto does not process nested chunks, and they are processed by the modx parser after the snippet is called.
Try to rewrite the assets/snippets/ditto/classes/ditto.inc.php near line 259 like this:

  function render($resource, $template, $removeChunk,$dateSource,$dateFormat,$ph=array(),$phx=1,$x=0) {

D
Dmitry Logvinenko, 2012-07-27
@dmlogv

I didn’t understand something: I commented out the chunk call in the ditto template and added a placeholder with phx next to it. I look at the code - everything is generated, in the comments too! How is that?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question