Event category classes in Events List Widget

Home Forums Calendar Products Events Calendar PRO Event category classes in Events List Widget

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #55882
    fenoco
    Participant

    Hi,

    I was wondering if it was possible to edit the list widget’s template so it adds the corresponding classes to the event element . I need to color code the events on the list by their category. I tried adding to the attribute in the element but it prints out nothing.

    Any thoughts? Thanks in advance.

    #56024
    reid peifer
    Member

    Hi Fenoco
    Super cool looking site that you’re working on. There is an override system in place so you can write your own versions of the views without editing the core plugin directly.

    Go to your theme folder make a new them called tribe_events. In tribe_events make another folder called widgets. Now you want to copy the list widget file into that folder.

    Go to the plugin folder > views > widgets and copy list-widget.php and paste it into the new widgets folder you’ve created. So when you’re done you should have
    yourtheme > tribe-events > widgets > list-widget.php

    Now we just need to modify the template to print out the categories within the class attribute.
    This code gist should do the trick: https://gist.github.com/reidpeifer/6034586

    #56027
    reid peifer
    Member

    Hey Fenoco – Note: There was a typo in the above comments. I have fixed it, but make sure that you title the new folder tribe-events and NOT tribe_events

    #56067
    fenoco
    Participant

    Hi Reid! Thanks for your comment, and your answer. We were aware of the override system, and we are using it. It’s great that you thought of that.

    We actually figured something out after creating the discussion so I’ll post it here for reference. We ended up doing this:

    ID, 'tribe_events_cat' );
    $term = array_pop($terms);
    /* foreach ($terms as $elterm) { echo $elterm->slug.' ' ; } */
    ?>
    <li class="slug; ?> cf"> Your event goes here.

    Works wonders. Thanks again!

    #56069
    fenoco
    Participant

    hmm… The code came up all wrong. This is it:

    ID, ‘tribe_events_cat’ );
    $term = array_pop($terms);
    /* foreach ($terms as $elterm) { echo $elterm->slug.’ ‘ ; } */
    ?>
    <li class="slug; ?> cf”>

    #56079
    reid peifer
    Member

    So glad you got it working. Thanks for sharing your solution.

    #57796
    fenoco
    Participant

    Actually this is the code:
    $terms = get_the_terms( $post->ID, ‘tribe_events_cat’ );
    $term = array_pop($terms);

    Then you can echo $term->slug; wherever you need.

    #58410
    Rob
    Member

    Thanks for the follow-up, fenoco. I’ve marked your newest reply as the answer 🙂

    It sounds like you’re all set for now, but if you do need anything down the road, don’t hesitate to let us know. Going to close out this thread though.

    #979742
    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 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Event category classes in Events List Widget’ is closed to new replies.