Home › Forums › Calendar Products › Events Calendar PRO › List View on Category Page
- This topic has 10 replies, 4 voices, and was last updated 10 years, 10 months ago by
Support Droid.
-
AuthorPosts
-
January 26, 2012 at 11:19 pm #14239
Brad
ParticipantI have the gridview as my default, but I find it advantageous if the list view were the default for viewing specific categories. I tried to simply create a category.php file, but that did not work. Do I need to add a if to the page-template?
January 27, 2012 at 7:56 am #14257Rob
MemberHey Brad. What exactly are you trying to do here? Have grid view as the default for when someone visits /events, but list view for all category pages?
January 27, 2012 at 9:06 am #14273Brad
ParticipantHi Rob. Yes.
Grid view for full calendar of all events at orbike.com/events
List view for event catetgores at orbike.com/events/category/race/The reasoning is simple, some months some categories are not or ever going to be populated. Should I set the default to list and force the grid on the main page?
January 27, 2012 at 1:14 pm #14287Brad
ParticipantHi Rob. Yes.
Grid view on orbike.com/events
List view on orbile.com/events/category/mt-bikeThe reasoning is that at times some categories have more events and seeing a list would show when events, even if they are more than a month out.
Should I set the default to list and make a new template for the main page that pulls up the grid?
January 27, 2012 at 3:18 pm #14294Jonah
ParticipantHey Brad, I think the easiest solution for this would be to conditionally check for these specific categories and if it is one, use a different URL containing the event list slug vs. the calendar.
The main place your event categories are displayed is in the single event view so you’ll want to first make a copy of /wp-content/plugins/the-events-calendar/views/single.php and place in an ‘events’ folder in your theme.
Next, find line 32 where tribe_meta_event_cats() is called. We’re going to replace that with a custom category (actually taxonomy because event categories are really taxonomies) display function.
global $post;
$event_cats = wp_get_object_terms($post->ID, 'tribe_events_cat');
if(!empty($event_cats)){
echo 'Category: ';
foreach($event_cats as $cat){
if($cat->term_id == 9) {
echo 'slug.'/">'.$cat->name.'';
} else {
echo 'slug, 'tribe_events_cat').'">'.$cat->name.'';
}
}
}
This get all the event categories just like before and displays them in basically the same way, but now you have the condition (if($cat->term_id == 9) {) to check for your category and use a different link appending “/upcoming” in between your calendar slug and the category prefix.
All you need to do to get this working in your setup is to change the term_id to the category you want to check for and add any others you want to check for. And then change the /calendar slug if you are using something different.
I hope that helps!
January 27, 2012 at 3:20 pm #14296Jonah
ParticipantSorry, code got botched, try this: http://pastebin.com/Qw9ywfiJ
January 29, 2012 at 11:06 pm #14346Brad
ParticipantHi Jonah,
I understand what you wrote up here, but I want to change how the ecp-page-template calls up the list or grid views. Your code gave me an idea. Here is what I wrote up: http://pastebin.com/pRCdWanU
You see what I am going for here. If a user clicks on a category slub link (anywhere) it brings up the ‘list’ view. If not, the current default template (as set within the ECP options panel).
Thanks for your comments.
January 30, 2012 at 10:10 am #14377Jonah
ParticipantHey Brad,
I see what you’re getting at but I can’t get that to work. I modified it a bit so it uses the is_tax conditional instead: http://pastebin.com/haEzrjBM
But, maybe that’s wrong… Sorry, I can’t spend any more time on this as it’s a customization but you may be on to something. Let us know what you find.
My code that I posted earlier does work for me although I noticed a slight mistype, make sure to add a forward slash after category in the URL…
Regards,
JonahJanuary 31, 2012 at 7:50 pm #14495Brad
ParticipantHi Jonah, you have done great work here. I find the ECP both very easily customization in some aspects and difficult in others. Thanks for your help. When I have a good solution, I will post it.
February 1, 2012 at 8:10 pm #14557Rob
MemberThanks Brad. Looking forward to seeing what you turn up 🙂
July 4, 2015 at 5:00 pm #975525Support 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 ‘List View on Category Page’ is closed to new replies.
