What is wrong with this code? It’s showing nothing. It used to work fine, and now it doesnt’. Without the ‘notempty’ it is showing children fine.
[[!getResources:notempty=`<div id="sidebar-nieuws" class="sidebar-item">
<h3>Nieuws</h3>
[[!getResources?
&parents=`23`
&tpl=`sidebar-nieuws-tpl`
&showHidden=`1`
&limit=`4`
&includeContent=`1`
&sortby=`menuindex`
&sortdir=`ASC`
&includeTVs=`1`
&processTVs=`1`
&tvPrefix=``
]]
</div>`]]
I believe for something like this you want to set up like:
<div id="sidebar-nieuws" class="sidebar-item">
<h3>Nieuws</h3>
[[!getResources:default=`No resources found`?
&parents=`23`
&tpl=`sidebar-nieuws-tpl`
&showHidden=`1`
&limit=`4`
&includeContent=`1`
&sortby=`menuindex`
&sortdir=`ASC`
&includeTVs=`1`
&processTVs=`1`
&tvPrefix=``
]]
The issue with this is you’re calling the snippet without parameters, then running another snippet (notempty) and then calling another snippet. This is resource-intensive and not ideal. Using default, if getResources returns empty, false or null (which I believe is returned when no data is found) it then shows the default option. In your default call, you could call a chunk or another getResources call with different parameters, but again this may have performance issues.
This works. But it shows ‘No resources found’ when there are nog resources. I could empty this text, but that’s not a solution.
The entire DIV should be hidden when no resources are found.
I found a smooth solution on:
https://docs.modx.com/current/en/extras/getresources#getResources-Examples
Wrapping a getResources result in other markup (like an &outerTpl property, which doesn’t exist for getResources from version 1.6.0 you can still do it like that or use the &tplWrapper property).
[[getResources? ... &toPlaceholder=`results`]]
[[+results:notempty=`<ol>[[+results]]</ol>`]]
BUT: there are still no results shown! The ‘notempty’ seems to be broken. This was my original question.