List View on Category Page

Home Forums Calendar Products Events Calendar PRO List View on Category Page

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #14239
    Brad
    Participant

    I 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?

    #14257
    Rob
    Member

    Hey 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?

    #14273
    Brad
    Participant

    Hi 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?

    #14287
    Brad
    Participant

    Hi Rob. Yes.

    Grid view on orbike.com/events
    List view on orbile.com/events/category/mt-bike

    The 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?

    #14294
    Jonah
    Participant

    Hey 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!

    #14296
    Jonah
    Participant

    Sorry, code got botched, try this: http://pastebin.com/Qw9ywfiJ

    #14346
    Brad
    Participant

    Hi 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.

    #14377
    Jonah
    Participant

    Hey 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,
    Jonah

    #14495
    Brad
    Participant

    Hi 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.

    #14557
    Rob
    Member

    Thanks Brad. Looking forward to seeing what you turn up 🙂

    #975525
    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 11 posts - 1 through 11 (of 11 total)
  • The topic ‘List View on Category Page’ is closed to new replies.