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.

How to display a message when

February 28, 2011 10:26pm

Subscribe [2]
  • #1 / Feb 28, 2011 10:26pm

    leemcalilly

    97 posts

    I’m setting up a calendar view that lets you page through channel entries by month. But some months will not have any entries.

    Is there a way to still display the month and a message like “there are no entries for this month” even though there are no posts for that month’s date range?

    The url for a page like this might be something like this:

    events/month/2011/02

  • #2 / Mar 01, 2011 4:24pm

    Ingmar

    29245 posts

    Have you tried using {if no_results}?

  • #3 / Mar 01, 2011 8:48pm

    leemcalilly

    97 posts

    {if no_results} worked, thanks!

    Now is there also a way to still display the current month at a url like: /events/month/2011/03 when there are no entries?

    Clearly the url is generating the month dynamically. Can I put that month in the template some how so it says something like, “There are no events for March”.

  • #4 / Mar 02, 2011 1:20pm

    Sue Crocker

    26054 posts

    In the if_no_results section, you could do some sort of checking for the last segment, and based on what it is, use the long version of the month name in a message. I’d tend to combine the month and year together. This would be more of a How Do I kind of question, which would fit better in the CodeShare Corner.

    I’d use SwitchEE which is a third party add-on over on Devot-ee.com.

    Does that help?

  • #5 / Mar 02, 2011 1:41pm

    leemcalilly

    97 posts

    That certainly points me in the right direction. Thanks!

  • #6 / Mar 02, 2011 3:57pm

    Ingmar

    29245 posts

    Glad to see that helped. Please post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases