ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Determining whether an entry is a single day or last for two or more days.

June 29, 2011 6:23am

Subscribe [4]
  • #1 / Jun 29, 2011 6:23am

    D.Warren

    2 posts

    I am trying to set up a scheduled closings section in a template. My hurdle is some closings are a single date and some are a date range that is two or more days.

    <ul>
          {exp:channel:entries channel="closings" show_expired="yes" status="Scheduled"
          show_future_entries="yes" year="{current_time format="%Y"}" orderby="date"}
          <li>{title} {entry_date format="%F the %j<sup>%S</sup>"}</li>
          {/exp:channel:entries}
    </ul>
    <ul>
          {exp:channel:entries channel="closings" show_expired="yes" status="Scheduled" 
          show_future_entries="yes" year="{current_time format="%Y"}" orderby="date"}
          <li>{title} {entry_date format="%F the %j<sup>%S</sup>"} through {expiration_date format="%F the %j<sup>%S</sup>"}</li>
          {/exp:channel:entries}
    </ul>

    I guess some sort of if statement could take care of this but not sure how to go about that, possibly some php. I am mainly a HTML/CSS guy so my php knowledge is lacking.

    EE2 v2.1.3
    http://new.zackhallmd.com/index.php/contact

    Thanks

    EDIT: This was my first post, looks like I should have posted it in “Community Help” not sure if it can be moved or I should delete and repost to “Community Help”?

    Moved to Community Help forum by Moderator

  • #2 / Jun 29, 2011 2:46pm

    Sue Crocker

    26054 posts

    Welcome to the ExpressionEngine forums, D.Warren. I’ll be happy to move it for you..

  • #3 / Jul 04, 2011 1:31pm

    D.Warren

    2 posts

    I was making this way more complicated than it was. All I needed to do was to compare the entry_date to the expiration_date.

    <ul>
            {exp:channel:entries channel="closings" show_expired="yes" status="Scheduled" show_future_entries="yes" year="{current_time format="%Y"}" orderby="date"}
        <li>
            {if {entry_date format="%m%d%Y"} != {expiration_date format="%m%d%Y"}}{title} {entry_date format="%F the %j<sup>%S</sup>"} through  {expiration_date format="%F the %j<sup>%S</sup>"}
            {if:else}{title} {entry_date format="%F the %j<sup>%S</sup>"}{/if}
        </li>
        {/exp:channel:entries}
    </ul>
  • #4 / Aug 21, 2012 3:27pm

    OrganizedFellow

    435 posts

    The above solution (post#2) should work for me,
    but it is not.
    I am using v2.5.0 - Build Date: 20120507.

    {if {entry_date format="%m%d%Y"} != {expiration_date format="%m%d%Y"} }
    ...
    {if:else}
    ...
    {/if}

    Instead, I get a PHP parse error.

    Parse error: syntax error, unexpected ')' in /home/xxx/public_html/system/expressionengine/libraries/Functions.php(680) : eval()'d code on line 135

    Anyone have a solution?

  • #5 / Aug 22, 2012 7:59am

    e-man

    1816 posts

    Try using either:

    {if '{entry_date format="%m%d%Y"}' != '{expiration_date format="%m%d%Y"}' }

    OR

    {if entry_date != expiration_date}
  • #6 / Aug 22, 2012 3:37pm

    OrganizedFellow

    435 posts

    Thanks e-man.
    Giving that a try.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases