1

I am using Calendar in an attempt to display an Event as a single entry. I have previous events and upcoming events. I need to display the "Current Event". In other words, if the event spans the dates 9-15-2015, 9-16-2015, and 9-17-2015 I need to display it if today is 9-16-2015. If there is NOT an event spanning the current date, I need to show the NEXT event in the calendar. I am using a single calendar for this site.

I want the user to be able to enter a 'range' or add rules as seperate days and times. For that reason, I have this in my date/time display:

{if event_has_rules}
    {rules}

    {/rules}
{/if}
{if event_recurs}
    {occurrences}
        <span style="color:#7e7f81;">{occurrence_start_date format="%l %m-%d-%Y"} &mdash; {occurrence_start_date format="%g:%i%a"} - {occurrence_end_date format="%g:%i%a"}</span></br>
    {/occurrences}
{/if}

I haven't quite figured the rules syntax without blowing up my template yet though...

My primary issue is with displaying the "current" event.

I have this right now:

{exp:calendar:events
    calendar_id="20"
    event_limit="1"
    date_range_start="{current_time format='%Y-%m-%d @ %h:%i %A'}"
    show_days="-14"
    dynamic="no"
}

I tried the -14 in an attempt to catch anything starting 14 days before the current day.

I also tried without the date_range_start in there at all.

1

With a little guidance from Solspace support, I changed to use the cal tag instead of the event tag in order to get in the date range I needed. The docs indicate being able to use the {event} tag pair inside, which you are, however the loop was not gathering the data as expected without providing an embed template and passing that embed template the {event_id}. I will attach what I ended up with below in full in hopes it may be useful to someone else.

Main template section for the event data:

{exp:calendar:cal
    calendar_id="20"
    date_range_start="today"
    date_range_end="today"
    pad_short_weeks="n"
}
    {display_each_day}
        {if day_event_total > 0}
            {events}
                <!-- Blog Post -->
                <div class="row">
                    <div class="span12 module_cont module_blog module_none_padding module_blog_page">
                        <div class="blog_post_page blog_post_preview has_pf">
                            <div class="preview_top">
                                <div class="preview_title">
                                    <h1 class="blogpost_title">{event_title}</h1>
                                    <div class="row">

                                        <div class="span4 module_number_9 module_cont pb50 module_iconboxes">
                                            <div class="listing_meta shortcode_iconbox">
                                                <a href="javascript:void(0)">
                                                    <div class="iconbox_wrapper">
                                                        <span class="ico"><i class="icon-calendar"></i></span>
                                                        <a><h6 class="iconbox_title">When</h6></a>
                                                        <div class="iconbox_body">
                                                            {embed="_includes/_event" event_id="{event_id}"}
                                                        </div>
                                                    </div>
                                                </a>
                                            </div>
                                        </div><!-- .module_cont -->

                                        <div class="span4 module_number_9 module_cont pb50 module_iconboxes">
                                            <div class="listing_meta shortcode_iconbox">
                                                <a href="javascript:void(0)">
                                                    <div class="iconbox_wrapper">
                                                        <span class="ico"><i class="icon-home"></i></span>
                                                        <h6 class="iconbox_title">Where</h6>
                                                        <div class="iconbox_body">
                                                            {address style="schema"}
                                                        </div>
                                                    </div>
                                                </a>
                                            </div>
                                        </div><!-- .module_cont -->

                                        <div class="span4 module_number_9 module_cont pb50 module_iconboxes">
                                            <img src="{address:static_map width='400' height='400' zoom='15'}" alt="{address style='inline'}" />
                                        </div>

                                    </div>
                                </div><!-- .preview_title -->
                            </div>

                            <div class="blog_post_content">
                                <article class="contentarea">{event_summary}</article>
                                <p>&nbsp;</p>
                            </div>


                            <div class="row">
                                <div class="span12 module_number_5 module_cont pb50 module_text_area">
                                    <div class="bg_title"><h5 class="headInModule">Terms and Conditions</h5></div>
                                    <div class="module_content">
                                        <blockquote class="shortcode_blockquote left type1">
                                            <div class="blockquote_wrapper">
                                                {terms_and_conditions}
                                            </div>
                                        </blockquote>
                                    </div>
                                </div><!-- .module_cont -->
                            </div>



                            <div class="row">
                                <div class="span12 module_number_19 module_cont pb0 module_divider"><hr></div><!-- .module_cont -->
                            </div>


                            <div class="row">
                                <div class="span12 module_number_14 module_cont pb60 module_gallery photo_gallery">
                                    <div class="bg_title"><h5 class="headInModule">Gallery</h5></div>
                                    <div class="list-of-images images_in_a_row_3">
                                        {sale_images}
                                            {if image:no_images}
                                                <div class="gallery_item">
                                                    <div>There are currently no images for this sale uploaded. Please check back.</div>
                                                </div>
                                            {/if}
                                            <div class="gallery_item">
                                                <div class="gallery_item_padding">
                                                    <div class="gallery_item_wrapper">
                                                        <a href="{image:url}" class="photozoom"></a>
                                                        <img class="gallery-stand-img" src="{image:url:small}" alt="{image:title}" />
                                                        <div class="gallery_fadder"></div>
                                                        <span class="featured_items_ico"></span>
                                                    </div>
                                                </div>
                                            </div>
                                        {/sale_images}
                                        <div class="clear"></div>
                                    </div>
                                </div><!-- .module_cont -->
                            </div>



                            <div class="blogpost_footer">
                                <div class="blogpost_share">
                                    {exp:sharethis:button
                                        services="facebook|pinterest|twitter|googleplus"
                                        display="hcount"
                                        title="{title}"
                                        url="{current_url}"
                                    }
                                    <div class="clear"></div>
                                </div>
                            </div>
                        </div>
                        <!--.blog_post_page -->
                    </div>
                </div>
                <!-- /Blog Post -->
            {/events}
        {/if}
    {/display_each_day}
{/exp:calendar:cal}

Then in the embed template:

{exp:calendar:events
    event_id="{embed:event_id}"
    event_limit="1"
    dynamic="no"
}
    {occurrences}
        <span style="color:#7e7f81;">{occurrence_start_date format="%l %m-%d-%Y"} &mdash; {occurrence_start_date format="%g:%i%a"} - {occurrence_end_date format="%g:%i%a"}</span></br>
    {/occurrences}
{/exp:calendar:events}

This achieved the data extraction I was after for the date ranges that differed.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.