(Using ModX 1.0.5)
When I execute my current snippet (see snippet below), it seems to completely ignore the if(empty())
checks.
I have also tried with if($promoX == '')
, also no luck.
<?php
$promo1 = '[*sidepromotop*]'; // assets/images/promo1.jpg
$promo2 = '[*sidepromobot*]'; // this variable is empty.
if(empty($promo1) && empty($promo2)){
echo '[!Ditto? &startID=`92` &depth=`1` &display=`2` &randomize=`1` &tpl=`Promo-Block-Styles`!]';
}else{
if(empty($promo1)){
echo '[!Ditto? &startID=`92` &depth=`1` &display=`1` &randomize=`1` &tpl=`Promo-Block-Styles`!]';
}else{
echo '<div class="promo"><img src="'.$promo1.'" alt="" /></div>';
}
if(empty($promo2)){
echo '[!Ditto? &startID=`92` &depth=`1` &display=`1` &randomize=`1` &tpl=`Promo-Block-Styles`!]';
}else{
echo '<div class="promo"><img src="'.$promo2.'" alt="" /></div>';
}
}
?>
The code above will for some reason display the following:
<div class="promo">
<img src="assets/images/promo1.jpg" alt="">
</div>
<div class="promo">
<img src="" alt="">
</div>
As you can see, even if the variable is empty, it apparently still treats it as not empty when I run it though my code.
I would really appreciate some insight on this, as I am very new to modx, and it is giving me such a headache!
Thanks!