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.

Calendar: expiration_date not rendering

September 05, 2007 8:33pm

Subscribe [3]
  • #1 / Sep 05, 2007 8:33pm

    Joseph Seliong

    3 posts

    Hello.

    I’m working with the calendar module, and everything seems to be working fine, except that the {expiration_date format="xxxx"} variable is not rendering (is that the right word?), i.e., it won’t give me the expiration date. Other date variables work fine, such as {entry_date format="%l, %j %F"}. The variable {expiration_date format="%g:%i %a"}, for example, will render exactly as ‘{expiration_date format="%g:%i %a"}’.

    The curious thing is that when I omit format=“xxxx” (where xxxx is the date variable formatting), I get a Unix time stamp, which shows that at least it’s getting a value.

    Here’s the simplified code:

    {entries}
        {entry_date format="%l, %j %F"}
        {entry_date format="%g:%i %a"} - {expiration_date format="%g:%i %a"}
        <a href="http://{title_permalink=events/eventdetails}">{title}</a>
    {/entries}

    I have absolutely no idea where I’ve screwed up, and I’m pretty sure it’s probably something really arcane like I’m not allowed to have 3 date variables in a row or something random like that!

    I would really appreciate any help! Thanks!

  • #2 / Sep 05, 2007 11:18pm

    Sue Crocker

    26054 posts

    Joseph, the exp:calendar tag doesn’t take entry_date or expiration_date. At least not in the docs.

    However, you are correct in that entry_date works, but expiration_date doesn’t.

    I’m not sure if this is a defect or a feature. You might be able to get around it by using the query module to pull out the expiration_date and format it that way.

  • #3 / Sep 12, 2007 9:40am

    Joseph Seliong

    3 posts

    Hi Sue,

    Sorry for my late reply, I had to fly halfway round the world!

    Anyway, thanks for the reply. I was reading this thread (http://ellislab.com/forums/viewthread/59482/) and I got the impression that the user is trying to use the expiration_date variable within the calendar module, or am I wrong about that?

    Thanks again!

  • #4 / Sep 12, 2007 10:23am

    Robin Sowell

    13255 posts

    I’m pretty sure that thread is focusing on the weblog entries tag.  The calendar doesn’t have all of the same variables available.

  • #5 / Sep 12, 2007 10:34am

    Joseph Seliong

    3 posts

    Hi Robin, thanks for the quick reply!

    Hmm, I suppose I’ll have to use the query module/PHP. Not looking forward to doing that! Just one more quick clarification: at the bottom of this wiki page ( http://expressionengine.com/wiki/Events_Calendar/ ) it says:

    When listing multi-day and single-day events, you can use PHP in your templates to conditionally display the end date as described in this forum thread.

    Is that using the same PHP technique/query module which Sue was referring to?

    Thanks!

  • #6 / Sep 12, 2007 11:11am

    Robin Sowell

    13255 posts

    Seems weird to me you’d get a time for the expiration date when you ditch formating.  If that’s the true expiration date, would be easy enough to format via php.  I’d try it out, but I don’t really have any expiration dates.

    Anyway- you can try this- see if it works:

    {entries}
    <?php
    global $LOC;
    $y = $LOC->convert_timestamp('%Y', '{expiration_date}', TRUE);
    $m = $LOC->convert_timestamp('%M', '{expiration_date}', TRUE);
    ?>
        {entry_date format="%l, %j %F"}
        {entry_date format="%g:%i %a"} - <?php echo $m.' '.$y; ?>
        <a href="http://{title_permalink=events/eventdetails}">{title}</a>
    {/entries}

    php parsed on output.  But- I’m not thinking why it would be there and unparsed.  Still, can give this a shot.  And I’m going to shift this one over to ‘how to’ as we’re getting into php.

  • #7 / Sep 12, 2007 1:54pm

    Joseph Seliong

    3 posts

    Cheers Robin! It worked!

    I changed some parameters:

    {entries}
            <?php
            global $LOC;
            $g = $LOC->convert_timestamp('%g', '{expiration_date}', TRUE);
            $i = $LOC->convert_timestamp('%i', '{expiration_date}', TRUE);
            $a = $LOC->convert_timestamp('%a', '{expiration_date}', TRUE);
            ?>
            {entry_date format="%l, %j %F"}
            {entry_date format="%g:%i %a"} - <?php echo $g.':'.$i.' '.$a; ?>
            <a href="http://{title_permalink=events/eventdetails}">{title}</a>
    {/entries}

    With the output being:

    Wednesday, 19 September
    8:00 pm - 11:30 pm Event Title

    Now my next challenge is to see if I can insert, say, the words “next day” if {expiration_date} != {entry_date}. I thought of doing it according to this thread (http://ellislab.com/forums/viewthread/25029/#110246) but it doesn’t work—all entries carry the text “next day” even if it doesn’t end the next day. Any suggestions?

    Again, thanks for your help, I really appreciate it!

  • #8 / Sep 13, 2007 1:03pm

    Robin Sowell

    13255 posts

    I think it should work- parsing is definitely on output- correct?  (Must be.)  So- did you try it like:

    {entries}
            <?php
            global $LOC;
            $g = $LOC->convert_timestamp('%g', '{expiration_date}', TRUE);
            $i = $LOC->convert_timestamp('%i', '{expiration_date}', TRUE);
            $a = $LOC->convert_timestamp('%a', '{expiration_date}', TRUE);
            $comp_exp = $g.$i.$a;
            $comp_entry = '{entry_date format="%g%i%a"}';
            ?>
            {entry_date format="%l, %j %F"}
            {entry_date format="%g:%i %a"} - <?php echo $g.':'.$i.' '.$a; ?>
            <a href="http://{title_permalink=events/eventdetails}">{title}</a>
            <?php if ($comp_exp != $comp_entry) { echo 'Next day'; } ?>
    {/entries}
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases