[[*services-in-room:notempty=``:and:*services-in-bathroom:notempty=``:and:*the-price-includes:notempty=``:then=`<a class="rooms-services">conteng</a>`]]
This question has been answered by multiple community members. See the first response.
[[*services-in-room:isnot=``:and:if=`[[*services-in-bathroom]]`:isnot=``:and:if=`[[*the-price-includes]]:isnot=``:then=`<a class="rooms-services">conteng</a>`]]
Output modifiers aren't able to handle that kind of multiple conditional. You'll need a custom snippet.How I can write this snippet?)
It is possible as far as I know (in Evo this worked):
[[*services-in-room:isnot=``:and:if=`[[*services-in-bathroom]]`:isnot=``:and:if=`[[*the-price-includes]]:isnot=``:then=`<a class="rooms-services">conteng</a>`]]
notempty is not a conditional modifier and you have to call the other TVs with if=`[[*tvname]]`
[[!CheckServices]]
/* CheckServices snippet */
$tvNames = array(
'services-in-room',
'services-in-bathroom',
'the-price-includes'
);
foreach($tvNames as $name) {
if (empty($modx->resource->getTVValue($name))) {
return '';
}
}
return '<a class="rooms-services">conteng</a>';
[[*services-in-room:isnot=``:and:if=`[[*services-in-bathroom]]`:isnot=``:and:if=`[[*the-price-includes]]`:isnot=``:then=`<a class="rooms-services">conteng</a>`]]
@Bob: Much faster is (almost) ignorable since it is used direct in the template and not in an iterated getResources chunk. And it is cacheable as far as I know.Thank you!
@Nort: There was an missing ` in the modifier chain:
[[*services-in-room:isnot=``:and:if=`[[*services-in-bathroom]]`:isnot=``:and:if=`[[*the-price-includes]]`:isnot=``:then=`<a class="rooms-services">conteng</a>`]]
Thats the true reason to avoid such long output filter chains. Nested conditionals could cause problems too and should be avoided.
A custom snippet will be much faster (untested):Thank you,Bob!
[[!CheckServices]]
/* CheckServices snippet */ $tvNames = array( 'services-in-room', 'services-in-bathroom', 'the-price-includes' ); foreach($tvNames as $name) { if (empty($modx->resource->getTVValue($name))) { return ''; } } return '<a class="rooms-services">conteng</a>';