1

I have a calendar. Currently viewable by year.

I need to add in a drop down/list of some sort which will show

January 2015
February 2015
...

When the user selects from the list I need to show only entires from that particular month. What is the correct way of achieving this?

I have the following in mind.

I pass variables to the URL either POST or GET so the url looks like

domain.com/calendar/january/2016
or
domain.com/calendar?month=january&year=2016

Then return the variables, using start_on & stop_before work some magic.

Similar as to above, I could pass some variables into a session & again use the content of the variables to affect my exp loop.

How would you perform this, is my logic sound or is there a simpler way?

1 Answer 1

0

Strangely I can't find this in the documentation, but you can filter entries dynamically by month by simply appending the year and month to the URL.

So given a standard channel:entries tag like this:

{exp:channel:entries channel="events"}

... /calendar/2015/01 will only show entries with an entry_date from January 2015.

On the resulting page, you can use the Date Heading tag pair to dynamically display the month:

{date_heading display="monthly"}
    <h1>{entry_date format="%F %Y"}</h1>
{/date_heading}

To generate your list of months to filter by, look a the Archive Month Links tag.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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