Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ditto is missing placeholders when built-in filters are enabled #187

Closed
pmfx opened this issue Aug 24, 2017 · 26 comments
Closed

Ditto is missing placeholders when built-in filters are enabled #187

pmfx opened this issue Aug 24, 2017 · 26 comments

Comments

@pmfx
Copy link

pmfx commented Aug 24, 2017

I have a simple Ditto call:

[[Ditto? 
&parents=`88` 
&display=`2` 
&tpl=`ditto-tpl-news` 
]]

and my ditto-tpl-news chunk is:

<div class="c-news">
  [[if? &is=`[+article_img+]:notempty` &then=`@TPL:ditto-tpl-news__img`]]
  <h3><a href="[~[+id+]~]">[+pagetitle+]</a></h3>
</div>

Chunk ditto-tpl-news__img parsed in by if snippet has empty placeholders like [+id+].

This only happens when core built-in filters are enabled.
Placeholders in ditto-tpl-news__img are back when I disable built-in filters.

Note: It works with filters enabled only if I move code from ditto-tpl-news__img directly into &then parameter of if snippet (no chunk).

@yama
Copy link

yama commented Aug 25, 2017

built-in filters are enabled

(test_chunk_1)
<div>
  [[if? &is=`[+test_tv+]:notempty` &then=`@TPL:test_chunk_2`]]
	<div><a href="[~[+id+]~]">[+pagetitle+]</a></div>
</div>
(test_chunk_2)
abcde
(In resource)
[[Ditto? 
    &parents=`15` 
    &tpl=`test_chunk_1` 
]]

This worked. Is something different?

@yama
Copy link

yama commented Aug 25, 2017

Disable built-in filters?

@pmfx
Copy link
Author

pmfx commented Aug 25, 2017

Thats not a problem. Try using placeholders like [+id+] in (test_chunk_2) Placeholders will be empty there. For example [+id+] in (test_chunk_2) have no value.

It works when I disable built-in filters.

@yama
Copy link

yama commented Aug 25, 2017

OK, thanks. I will fix it later.

@pmfx
Copy link
Author

pmfx commented Aug 25, 2017

@yama with this commit it is almost working. One more thing here.

In (test_chunk_2) I have phpthumb call:

(test_chunk_2)
<p>Image path: [+article_img+]</p>
[[phpthumb? &input=`[+article_img+]` &options=`w=200,h=200,zc=1,q=80`]]

[+article_img+] placeholder - even though it have value - is still empty in phpthumb call there.

@yama
Copy link

yama commented Aug 28, 2017

ok, I'll fix it later

@yama
Copy link

yama commented Aug 28, 2017

hmm...?
Is this problem related to Ditto? Is not it an issue with 'if' snippets?

@yama
Copy link

yama commented Aug 28, 2017

Ditto > if > phpthumb
The placeholder values(each docs and tv) obtained by Ditto does not reach phpthumb.
It might be possible to use $modx->mergePlaceholderContent() instead of $modx->parseText().

@pmfx
Copy link
Author

pmfx commented Aug 28, 2017

@yama I don't know what happened, but now first item in Ditto list have no placeholder at all. Second list item is OK.

@pmfx
Copy link
Author

pmfx commented Aug 28, 2017

In Ditto item tpl I have:

[[if? &is=`[+article_summary+]:notempty` &then=`not empty` &else=`empty`]]

"article_summary" TV is empty but "if" is wrong.

If I add to item tpl

[[if? &is=`[+article_img+]:notempty` &then=`@TPL:ditto-tpl-news__img`]]

All placeholders are lost.

@Dmi3yy
Copy link

Dmi3yy commented Aug 28, 2017

plz check now

2c0ad14

@pmfx
Copy link
Author

pmfx commented Aug 28, 2017

Almost perfect! Great job.

Still have issue with this #187 (comment)

"ditto-tpl-news" chunk:

<div class="c-news">
  [[if? &is=`[+article_img+]:notempty` &then=`@TPL:ditto-tpl-news__img`]]
  <h3><a href="[~[+id+]~]">[+pagetitle+]</a></h3>
</div>

"ditto-tpl-news__img" chunk:

<div class="c-news__img">
  <a href="[~[+id+]~]">
    <img src="[[phpthumb? &input=`[+article_img+]` &options=`w=200,h=200,zc=1,q=80`]]" alt="[+pagetitle:esc+]">
  </a>
</div>

Result: phpthumb shows "noimage" image.

BUT this works and thumb is displayed:

"ditto-tpl-news" chunk:

<div class="c-news">
  [[if? &is=`[+article_img+]:notempty` &then=`
    <div class="c-news__img">
      <a href="[~[+id+]~]">
        <img src="[[phpthumb? &input=`[+article_img+]` &options=`w=200,h=200,zc=1,q=80`]]" alt="[+pagetitle:esc+]">
      </a>
    </div>
  `]]
  <h3><a href="[~[+id+]~]">[+pagetitle+]</a></h3>
</div>

@Dmi3yy
Copy link

Dmi3yy commented Aug 29, 2017

I think this bug with IF he is not understand [+article_img+] in @tpl

@pmfx
Copy link
Author

pmfx commented Aug 29, 2017

@Dmi3yy I'm not sure.

"ditto-tpl-news__img" chunk:

<div class="c-news__img">
  <a href="[~[+id+]~]">
    [+article_img+]<br>
    <img src="[[phpthumb? &input=`[+article_img+]` &options=`w=200,h=200,zc=1,q=80`]]" alt="[+pagetitle:esc+]">
  </a>
</div>

Result:

screenshot_1

So IF has access to this [+article_img+] placeholder but somehow it is lost in phpthumb there.

@yama
Copy link

yama commented Aug 29, 2017

I want simple test case. Perhaps phpThumb and link tags do not matter, right?

"test_chunk_1" chunk:

<div>
  [[if? &is=`[+img+]:notempty` &then=`@TPL:test_chunk_2`]]
  <div>[+pagetitle+]</div>
</div>

"test_chunk_2" chunk:

<div>
    img src="[+img+]"
</div>

in resource:

[[Ditto? 
    &parents=`15` 
    &tpl=`test_chunk_1` 
]]

I will test this. ok?

@pmfx
Copy link
Author

pmfx commented Aug 29, 2017

Sure. This works (no phpthumb call).
But it don't work when you add phpthumb call to test_chunk_2 like:

<div>
  <img src="[[phpthumb? &input=`[+img+]` &options=`w=200,h=200,zc=1,q=80`]]">
</div>

@yama
Copy link

yama commented Aug 29, 2017

"test_chunk_1" chunk:

<div>
  [[if? &is=`[+img+]:notempty` &then=`@TPL:test_chunk_2`]]
  <div>[+pagetitle+]</div>
</div>

"test_chunk_2" chunk:

<div>
    img src="[[phpthumb? &input=`[+img+]` ]]"
</div>

in resource:

[[Ditto? 
    &parents=`15` 
    &tpl=`test_chunk_1` 
]]

Thanks for reply, I will test this. ok?

@pmfx
Copy link
Author

pmfx commented Aug 30, 2017

OK, I still get path to "noimage" as a result.

@yama
Copy link

yama commented Aug 30, 2017

ok, I will repair this later

@Deesen
Copy link

Deesen commented Sep 9, 2017

Hmm I used a fresh install of latest dev and the evo demo-content. In my case it works (Yama´s test-case) so I cannot recreate this issue. {{test_chunk_2}} returns correct thumbnails for me.

@pmfx
Copy link
Author

pmfx commented Sep 9, 2017

Hm, thats good news. Is there a way to fix it somehow on working 1.3.6 site?

@Deesen
Copy link

Deesen commented Sep 9, 2017

I am not sure, maybe try replacing ditto.class.inc.php ?

@pmfx
Copy link
Author

pmfx commented Sep 9, 2017

Nope, didn't work.

@yama
Copy link

yama commented Sep 9, 2017

#187 (comment)
It has no problem in my environment. Do you have any other information that might be helpful?

@pmfx
Copy link
Author

pmfx commented Sep 9, 2017

I have this problem on both dev version and 1.3.6. PHP 5.6.31.
But I found that it works when I add parameter to "test_chunk_2" in "if" call:

[[if? &is=`[+img+]:notempty` &then=`@TPL:test_chunk_2?&img=`[+img+]``]]

@yama
Copy link

yama commented Sep 11, 2017

Thanks. I want to know the case where a problem occurs. Is there anything else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants