0

I'm using the exp:calendar:events tag with Solspace Calendar. Is there a convenient way to output a year header, similar to exp:channel:entries in my events output?

Thanks!

2

How about something similar to the method using PHP described here?: Solspace's Date Field Filter - can it do date headings?

I'll rehash the answer here with modifications:

Basically, display a heading when the first occurrence of a year is encountered, and store it in a PHP array to avoid displaying the same year again.

<?php $heading = array(); ?>
{exp:calendar:events /* your other parameters here */}

    <?php if( ! isset($heading['{event_start_date format="%Y"}']) ) :?>
        <h2>{event_start_date format="%Y"}</h2>
        <?php $heading['{event_start_date format="%Y"}'] = '{event_start_date format="%Y"}'; ?>
    <?php endif ?>

    // Your other code

{/exp:calendar:events}

Don't forget to enable PHP for your template.

By the way, if you're looking for a chronological list of events, you should use {exp:calendar:cal} instead of {exp:calendar:events}. {exp:calendar:cal} will order occurrences stemming from different event entries in the correct timeline order. In other words, occurrences that overlap on a timeline will be ordered correctly and chronologically (e.g. AABABABBB instead of AAAABBBBB). See this more detailed explanation page for more details: http://www.solspace.com/docs/calendar/getting_started/

| 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.