pdoResource if notempty

Hello,

again a topic about pdoResource (i love pdoTools!).

I want to make a PDO call like this:

[[!pdoResources:empty=`[[$pdo_empty]]`?
&parents=`1`
&tpl=`pdo_tpl` 
&limit=`30`
]]

if contents are present in the call, then it should output the chunk [[$pdo_notempty]] AFTER THE PDO CONTENT else [[$pdo_empty]]

if i use

[[!pdoResources:notempty=`[[$pdo_notempty]]`?
&parents=`1`
&tpl=`pdo_tpl` 
&limit=`30`
]]

then i get only the Chunk without content…

do you know a way with good performance?

1 Like

Can you put the contents of pdo_notempty into the pdoResources snippet by chance? Perhaps use the tplWrapper property to insert it?

If so, then you can continue to use the empty output filter like your first example and use the tplWrapper for the notempty output.

3 Likes

Hi @joe-petts,

PDOtools is a great extra indeed. I use it since the begging of my journey with Modx 5 years ago.

Here is an example of what I use frequently that will do exactly what you asked for, and ties perfectly with what @markh shared:

[[pdoResources:default=`[[$EmptyPdoResourcesResults]]`?
   &parents=`[[*id]]`
   &tplWrapper=`pdo_tplWrapper`
   &tpl=`pdo_tpl` 
   &limit=`30`
]]

Be aware that calling pdoResources uncached can represent a big increase on the page load time. Don’t forget to remove the exclamation mark when the call is finished :slight_smile:

Cheers

2 Likes

Great. Many thanks for the optimal solution. This is exactly what I was looking for.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.