Conditional display in loop

General discussions about WebYep
Post Reply
msealey
Posts: 2
Joined: Sat Oct 22, 2011 12:15 am

Conditional display in loop

Post by msealey » Sat Oct 22, 2011 12:25 am

Loving WebYep :-) !

I have a (RTF) loop similar to this one:

Code: Select all

<?php foreach (WYLoopElement::aLoopIDs(teachers) as $webyep_oCurrentLoop->iLoopID) { $webyep_oCurrentLoop->loopStart(true); ?>
   Name: <?php webyep_richText("name", false, "../styles.css", true); ?>

   Email: <?php webyep_richText("email", false, "../styles.css", true); ?>

<?php $webyep_oCurrentLoop->loopEnd(); } ?>

How do I have the email field display only when it's populated, when it's not empty, please?

In other words if there is no value for that field, if it's empty (because there is no valid email to be entered by the editor), I don't want it to display at all on the finished page; of course it must be visible to the editor while the page is being edited.

I'm no PHP expert. Is it possible in WebYep conditionally to display a field like this, please?

TIA!

marcus
Objective Development
Objective Development
Posts: 170
Joined: Tue Nov 30, 2010 1:25 pm

Re: Conditional display in loop

Post by marcus » Sat Oct 22, 2011 12:49 pm

msealey wrote:Is it possible in WebYep conditionally to display a field like this, please?

No, that's not possible.

Eelco
Rank 1
Rank 1
Posts: 25
Joined: Sun Sep 18, 2011 1:50 pm

Re: Conditional display in loop

Post by Eelco » Mon Nov 07, 2011 4:16 pm


msealey
Posts: 2
Joined: Sat Oct 22, 2011 12:15 am

Re: Conditional display in loop

Post by msealey » Mon Nov 07, 2011 5:16 pm

Thanks, Eelco

Eelco
Rank 1
Rank 1
Posts: 25
Joined: Sun Sep 18, 2011 1:50 pm

Re: Conditional display in loop

Post by Eelco » Tue Nov 08, 2011 12:10 pm

Your'e welcome.
When all browsers are ready for css3 you could also use the :empty pseudo class. Does not work in IE8 (maybe in 9) but has full support in Safari 3.1, Firefox 3, Opera 9.5 and Chrome 2.

Post Reply