1

My markup:

<section id="box">
<ul id="slide">
<li></li>
<li></li>
<li></li>
</ul>
</section>

I want to show the section box only if date condition matches to todays date and then further loop the li tags.If it does not then I completely want to ingore the entire box.

This is what I am doing:

<section id="box">
    <ul id="slide">
{exp:channel:entries channel="LIVE_STREAM"}
    <li></li>
{/exp:channel:entries}
    </ul>
 </section>

How do I put a conditional check right above the section.In php it would have been quite easy,but in expression engine how can I do it?

1

If you use some custom text field to keep timestamp, in this case I think you need activate php and set it to be parsed on "input":

<?php
        $beginOfDay = strtotime("midnight", ee()->localize->now);
        $endOfDay   = strtotime("tomorrow", $beginOfDay) - 1;
?> 

    {exp:channel:entries channel="LIVE_STREAM"  search:timestamp_field="<<?php echo $endOfDay; ?>" search:timestamp_field="><?php echo $beginOfDay ?>"}
{if count == 0}
<section id="box">
        <ul id="slide">
{/if}
        <li></li>
{if count == total_results}
   </ul>
     </section>
{/if}
{/exp:channel:entries}
7
  • i want to loop over li only...and that to when the count is more than zero..so should I like use the same tags inside the ul?
    – user2133
    Feb 25 '14 at 7:45
  • what do you use for date? is it entry date or it is some field_type?
    – Max Lazar
    Feb 25 '14 at 7:55
  • just for sure - count in EE is not how many entries you have (is total_results). In case if total_results is 0, channel tag will not proceed nothing inside tags expect cond {if no_results} content {/if}. All other items out side no_results will be ignored.
    – Max Lazar
    Feb 25 '14 at 8:04
  • i have created a channel field which has timestamp..and if that field matches todays date then i want to loop over...
    – user2133
    Feb 25 '14 at 8:31
  • I made update for you. If you use just a text field to keep timestamp, I don't think that use condition to match the date in the loops is good solution.
    – Max Lazar
    Feb 25 '14 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy