Hello,
i am new to Modx Revolution and i try to archieve a very simple task:
I do have a template-variable [[*newstext]] with inputtype: rich text field and outputtype: text.
Some pages on my site may have news, others may not have.
So i want a
snippet to
check wether this template-variable is empty or not and if if is not empty i want to output a message.
Here is what i tried in my snippet:
1. Submit the template-variable to a php variable
$newstext = '[[*newstext]]';
2. Check if the variable is empty and if it is NOT empty echo it.
if ($newstext){
echo"<div id='news3'>[[*newstext]]</div>
}
My problem is that even when [[*newstext]] is empty (no text in the rich text field)
shows up in the source-code of the page.
The variable$newstext contains no visible content - i tried that with echo $newstext; and it didn't show anything
I also tried:
but still the div's were shown.
Here is the complete code:
<?php
$newstext = '[[*newstext]]';
if ($newstext != ''){
echo"<div id='news3'>[[*newstext]]</div>";
}
?>
I'd be so glad if you could help me with that. I spent about 2 hours now on Google and the forums but couldn'd find what is wrong with my constuction.
Thanks in advance,
Phil
[ed. note: philhippos last edited this post 15 years, 2 months ago.]