WordPress.org

Ready to get started?Download WordPress

Forums

Event Organiser
[resolved] Color Code for Venues instead of Categories? (8 posts)

  1. iamharlan
    Member
    Posted 1 year ago #

    I have a calendar working for concerts at two different venues that I'd like to have on the same calendar. However, I'd like to see them as a different color for the different venues. For example, blue for Venue A and red as Venue B. Is this possible?

    http://wordpress.org/extend/plugins/event-organiser/

  2. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    You can associate a colour to a venue using by creating adding a custom metabox to the venue page and storing the colour as venue meta (see this page on saving/retrieving venue meta data).

    However, there is not (yet) anyway to filter the ajax response for the calendar, or indeed the event colour to replace it with some other value. This will be added in 1.6 (due end of this month).

    So it will be possible.

    I'll try to remember to post here details of how to filter the event colour - if I forget, feel free to bump this thread.

  3. iamharlan
    Member
    Posted 1 year ago #

    Yeah, that would be really helpful. I think that's the only thing holding me back from this being the perfect plugin for our use.

    Thanks!

  4. iamharlan
    Member
    Posted 1 year ago #

    Stephen...were you able to add this feature?

  5. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    The filter has been added, buts its till in beta. It's almost ready to go but I want to do some checks (and have others do the same) before releasing). You can find the latest beta release on GitHub (dev branch): https://github.com/stephenh1988/Event-Organiser/tree/dev

    It's pretty stable - but I wouldn't recommend using it on a live site just yet.

    You'll still need to add a custom metabox to the venue page and store the colour as venue meta. Then using that filter (eventorganiser_event_color) you can change the event colour:

    add_filter('eventorganiser_event_color','my_change_event_color',10,2);
    function my_change_event_color( $color, $event_id ){
       $venue_id = eo_get_venue($event_id);
       $new_colour = '#ff0000';//Get colour of event, from the venue
       return $new_colour;
    }

    Note caching might mean your changes aren't immediate - you can update an event to clear the cache.

    I'll post some code on how to store/update a venue's colour shortly.

  6. iamharlan
    Member
    Posted 1 year ago #

    Thanks a ton. Here's what I've got so far. Apologies, I'm a bit inexperienced with plugin development.

    //Metabox for saving color of venue
    
    add_action('add_meta_boxes','my_add_metabox');
     function my_add_metabox(){
          add_meta_box('my_id','Venue Color', 'my_metabox_callback', 'event_page_venues', 'side', 'high');
     }
     function my_metabox_callback(){
        //Metabox's innards:
        $venuecolor = eo_get_venue_meta($venue->term_id, '_venue_color',true);
    
        //Remember to use nonces!
        wp_nonce_field( 'my_venue_meta_save', 'my_plugin_nonce_field' );
        ?>
        <label>Color:</label>
        <input type="text" name="my_venue_color" value="<?php echo esc_attr($venuecolor);?>" >
        <?php
     }
    
     add_action ('eventorganiser_save_venue','my_save_venue_meta');
    function my_save_venue_meta( $venue_id ){
    
        //Check permissions
        $tax = get_taxonomy( 'event-venue');
        if ( !current_user_can( $tax->cap->edit_terms ) )
            return;
    
        //Check nonce
        check_admin_referer('my_venue_meta_save', 'my_plugin_nonce_field');
    
        //Retrieve meta value(s)
        $value = $_POST['my_venue_color'];
    
        //Update venue meta
        eo_update_venue_meta($venue_id,  '_venue_color', $value);
        return;
    }

    This has created the metabox ok, but it doesn't seem to be storing the value yet.

    Once that's working, I'll add the filter below that code, and whatever I save in that metabox will then become the venue color for the calendar?

    Thanks again!

  7. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    I think it probably is - but the example on the page I linked to is a bit buggy. Try adding $venue as an argument to the my_metabox_callback() function:

    function my_metabox_callback( $venue ){
    ...
    }

    Then in my previous post:

    $new_colour = eo_get_venue_meta($venue_id, '_venue_color',true);

  8. Stephen Harris
    Member
    Plugin Author

    Posted 1 year ago #

    This should now be do-able - 1.6. was released earlier today. See http://wp-event-organiser.com/blog/1-6-released/ for more information.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.