Home › Forums › Calendar Products › Events Calendar PRO › Calendar Widget with different categories for different pages
- This topic has 11 replies, 3 voices, and was last updated 10 years, 10 months ago by
Support Droid.
-
AuthorPosts
-
November 28, 2012 at 1:02 pm #28644
James
ParticipantI’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?
November 29, 2012 at 7:06 am #28676Barry
MemberHi 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.
November 29, 2012 at 7:11 am #28678Barry
MemberActually, 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.
November 29, 2012 at 7:40 am #28679Barry
MemberOK, 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 🙂
November 29, 2012 at 12:08 pm #28707James
ParticipantThanks 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
November 29, 2012 at 12:34 pm #28709Barry
MemberWell, 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?
November 29, 2012 at 12:52 pm #28712James
ParticipantThanks 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.
November 29, 2012 at 1:24 pm #28715Barry
MemberIs 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?
November 29, 2012 at 2:32 pm #28724Barry
MemberHi 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.
November 29, 2012 at 3:07 pm #28725James
ParticipantOops.. Working now. Thanks Barry
November 29, 2012 at 3:18 pm #28727Barry
MemberNo problem, glad you’ve got it working 🙂
July 7, 2015 at 6:26 am #978257Support Droid
KeymasterThis 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. -
AuthorPosts
- The topic ‘Calendar Widget with different categories for different pages’ is closed to new replies.
