Display Current Month Title Being Viewed in Calendar Grid View

Home Forums Calendar Products Events Calendar PRO Display Current Month Title Being Viewed in Calendar Grid View

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #46343
    likemindsdesigns
    Participant

    Hello,
    I want to display the Month Name and Year of the month being viewed in Calendar Grid View. For example, if the user is looking at April 2013, I want it to say “April 2013” above the calendar. Then if they click the next arrow, I want it to say “May 2013” above the calendar.

    I have tried using the functions in my calendar grid view template ‘tribe_get_current_month_text()’ and ‘tribe_get_displayed_month()’ but they only display April (the current month). How do I get the text displayed for the month VIEWED.

    #46344
    likemindsdesigns
    Participant

    By the way, the function ‘tribe_get_displayed_month()’ does display the Month Year like I want it to.

    However, my problem is that it only shows correctly if I force refresh my browser each time a view a different month. So the calendar refreshes the Ajax but not the browser when I use the next/previous links.

    #46374
    Jonah
    Participant

    Hi likemindsdesigns,

    You should be able to accomplish this by using the following in your /wp-content/plugins/the-events-calendar/views/gridview.php file. Make sure to make a copy and place in an ‘events’ folder before you make changes. I added this to line 22 and it works for me: http://snippi.com/s/9qmtppj

    Does that help?

    #46428
    likemindsdesigns
    Participant

    Hi Jonah,
    No, the problem with that is that the month “April” displays even when a user hits the May–> forward button. The only way to get the correct month to display is to refresh the page. However, the calendar refreshes the Ajax, and not the overall page. How can I force refresh?

    http://mscra.com/events/2013-03/
    http://mscra.com/events/2013-04/
    (By the way, wish there was a way to send screen captures to illustrate problem). Thank you for your help!

    #46453
    likemindsdesigns
    Participant

    ** SOLVED **
    I am posting this solution if it will help any other users.

    FIRST, I was placing the function to get month text outside of the Ajax div. By placing it inside, I was able to get the refresh feature I wanted.
    SECOND, I created a new function to get current year text. I added this function to the file “calendar.php”:
    /**
    * Current Year Text
    *
    * Returns a textual description of the current year
    *
    * @return string Name of the current year.
    * @since 2.0
    */
    function tribe_get_current_year_text( ) {
    return date( ‘Y’, strtotime( tribe_get_month_view_date() ) );
    }
    THIRD, I updated my “gridview.php” template to include this line:

    I hope this will help someone. Thank you for your help Jonah! I suggest adding that Get Year text function to the next release.

    #46454
    likemindsdesigns
    Participant

    Include this line in gridview.php:

    #46455
    likemindsdesigns
    Participant

    Ok, sorry it is not letting me post PHP code. Basically you want to add the line to echo the functions to get month text and join that with get year text. Hope this will help!

    #46513
    Jonah
    Participant

    Hi likemindsdesigns,

    Thanks for posting your solution. Sorry about our code posting troubles, I suggest posting to code to http://snippi.com/ and then sharing the link here.

    Regards,
    Jonah

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Display Current Month Title Being Viewed in Calendar Grid View’ is closed to new replies.