Conditional visible newsbox

About the template and stylesheet - and changing the menu
Post Reply
Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Conditional visible newsbox

Post by Tata » Sun Mar 01, 2015 11:04 am

I had it before, but now I can't find how to make a newsbox visible onlz if there is any content on respective "newsbox-page".
IOW
To show the newsbox onlz if there is something written on the page and hide it from template if the page is empty.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Conditional visible newsbox

Post by cmb » Sun Mar 01, 2015 12:04 pm

Tata wrote:how to make a newsbox visible onlz if there is any content on respective "newsbox-page".
Simplest case:

Code: Select all

<?php if ($temp = newsbox('News')) echo $temp?>
More complex case where you want to show/hide additional HTML markup:

Code: Select all

<?php if ($temp = newsbox('News')):?>
<div class="newsbox">
  <?php echo $temp?>
</div>
<?php endif?>
Christoph M. Becker – Plugins for CMSimple_XH

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Conditional visible newsbox

Post by Tata » Sun Mar 01, 2015 1:54 pm

Thanks, that's it. I have forgotten about the $temp.
But how would it sound if I want:
Showing some general NewsboxContent if the real NewsboxPage is empty and the NewsboxPage only if it has any content?
IOW
While there is no "NEWS!!!" message on the NewsboxPage a "WelcomePoster" would be shown in the newsbox. Another day I write some NEWS!!! and it will show up replacing the "WelcomePoster".
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Post Reply