Calendar Widget with different categories for different pages

Home Forums Calendar Products Events Calendar PRO Calendar Widget with different categories for different pages

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #28644
    James
    Participant

    I’m working on a hockey website that supports three different teams. What I want to do is have the Events Calendar widget only display the games for that team when the user is on that page (PeeWee games in the widget when on the PeeWee page, Bantam games in the widget when on the Bantam page, Midget games in the widget when on the Midget page). I’ve created categories for the three different teams. How do I get the widget to show a specific category of events?

    #28676
    Barry
    Member

    Hi James – please familiarize yourself with template overrides first of all – what we would need to do here is create a custom table-mini.php template.

    Within the default template you will find a line that looks like this:

    $eventPosts = tribe_get_events(array( 'eventDisplay'=>'month' ) );

    Delete (or comment out) that line only and replace it with this code … you will of course have to change the page slugs detailed in the switch block and also the category slugs to suit your own requirements.

    Hopefully that gives you a good starting point, though.

    #28678
    Barry
    Member

    Actually, might have been a bit premature there James: that code will only work on the first page load – once visitors navigate forward or backward in time the effect is lost.

    So … it could be this is a bit more involved.

    #28679
    Barry
    Member

    OK, let’s try again!

    To make the custom categories persist between ajax requests (that’s to say, when a visitor navigates back/forwards using the mini calendar widget) we need to add some additional code, nothing too major though.

    Instead of my initial instructions, please replace this line:

    $eventPosts = tribe_get_events(array( 'eventDisplay'=>'month' ) );

    With this slightly modified snippet. We also need to replace the JS code that facilitates ajax navigation.

    In your theme’s functions.php file, add this snippet. Now we need to put our modified version of that JS code in place.

    What I’d suggest is creating a js directory inside your theme (unless one exists already). In that file, place this code. And with that done, you should be good to go 🙂

    #28707
    James
    Participant

    Thanks Barry. I’ve gone ahead and done those steps as outlined in your last post. How do I now call those categories in the widget? ie. How do I add that widget and say “display the peewee category”? We are using widget logic to put different calendars on different pages etc. Hope that makes sense.

    Thanks

    #28709
    Barry
    Member

    Well, so although the actual page and category slugs may be different in your case let’s just pretend they are as per my code.

    If the widget is displaying on abc.com/peewee-schedule then it ought to only display events that belong to the peewee category. If the current page doesn’t match any of those slugs (peewee-, bantam- or midget-schedule) then it should “stand down” and display all events as normal.

    Does that answer your question?

    #28712
    James
    Participant

    Thanks Barry. That makes sense. Ok, we’ve created an event and added it to the peewee page (http://badlandsaahockey.ca/peewee-schedule/) and set the slugs accordingly, but now we dont’ see any any events in any categories at all.

    #28715
    Barry
    Member

    Is it possible for you to provide a username and password (if happy to do so, please send an email for my attention to [email protected]) so I can look at your set-up?

    #28724
    Barry
    Member

    Hi James, so I took a look and it seems you left the category slugs in events/table-mini.php as per my snippet, for instance peewee when the actual event category slug you have set up is peewee-schedule, so you’d need to correct that for each category.

    #28725
    James
    Participant

    Oops.. Working now. Thanks Barry

    #28727
    Barry
    Member

    No problem, glad you’ve got it working 🙂

    #978257
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Calendar Widget with different categories for different pages’ is closed to new replies.