Use pdoResources to display content from (multiple) MIGX TVs

I have several resources that contain MIGX TVs to hold their content. Now I want to grab specific parts of those MIGX TVs to display like a teaser on the front page. It’s basically working, but I’m having a few issues.

The first issue is, that the images are just displayed as JSON string:

{ "sourceImg": { "src": "img1.jpg", "width": 1000, "height": 300, "source": 2 }, "crop": { "x": 0, "y": 0, "width": 1000, "height": 300 }, "targetWidth": 0, "targetHeight": 0, "altTag": "Image 1" }

Here is my pdoResources call:

[[pdoResources?
    &parents=`0`
    &where=`{"template:=":11}`
    &tpl=`spotlight`
    &includeTVs=`teaser,contents`
    &processTVs=`1`]]

And the spotlight tpl:

<div class="content">
    <h2>[[+pagetitle]]</h2>
    <p>[[!getImageList? &value=[[+tv.teaser]] &tpl=`@CODE:[[+text]]`]]</p>
</div>
<div class="image">
    [[!getImageList? &value=`[[+tv.contents]]` &tpl=`@CODE:[[+image]]`]]
</div>

The image itself is included as an Image+ TV within the MIGX TV contents.

→ 1. How can I make the images be processed correctly?

And the second issue is, that as soon as there is a ? within the [[+text]] the whole text is not shown, as I’m assuming the ? breaks the getImageList call. I tried to use a tpl with the applied output filter htmlent but no luck.

→ 2. How can I avoid any “special” characters within the [[+text]] breaking the code?

Maybe you need to add the missing backticks (`) for &value= in your first call to getImageList.

[[!getImageList? &value=`[[+tv.teaser]]` &tpl=`@CODE:[[+text]]`]]

Or maybe you have to use a chunk as the template in the getImageList call (instead of the @CODE: inline template).

And to output the Image+ image correctly, I believe you have to call [[ImagePlus? &value=`[[+image]]`]] in that chunk.

1 Like
  1. Use the ImagePlus snippet to display imagePlus values
  2. Use real tpl-chunks or try to replace [[…]] with {{…}} within Inline Chunks, that it doesn’t get parsed, before getImageList gets parsed.
  3. Call everything cached, also getImageList
1 Like

Another possibility is to call pdoResources without including the TVs and then call getImageList in the spotlight-template with the docid property.

<div class="content">
    <h2>[[+pagetitle]]</h2>
    <p>[[getImageList? &docid=`[[+id]]` &tvname=`teaser` &tpl=`tplTeaser`]]</p>
</div>
...
1 Like

That fixed the issue! Now it’s working both with inline code or a chunk. Although, I think as @bruno17 mentioned, it’s probably a good practice to use chunks here (especially when planning on using any filters).

You guys did it! I updated my code to:

// spotlight tpl
<div class="content">
    <h2>[[+pagetitle]]</h2>
    <p>[[getImageList? &value=`[[+tv.teaser]]` &tpl=`spotlightText`]]</p>
</div>
<div class="image">
    [[getImageList? &value=`[[+tv.contents]]` &tpl=`spotlightImage`]]
</div>


// spotlightImage tpl
[[ImagePlus? &value=`[[+image]]` &type=`tpl` &tpl=`imgSpotlight`]]


// imgSpotlight tpl
<img src="[[+url]]" alt="[[+alt]]" />

(Note to self: find a better template naming convention)

Fixed that as well! Thanks again for all the help!

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.