Builder Blocks: Events - Example Customizations

(Difference between revisions)
Jump to: navigation, search
(Created page with "== How to assign a layout to Events listing page == Add this code at the end of active theme's (child theme of Builder) functions.php: <pre class="brush:php;"> function cust...")
 
Line 94: Line 94:
 
}
 
}
 
</pre>
 
</pre>
 +
 +
=See also=
 +
 +
*[[Builder_Restaurant_Block:_Customizations|Builder Restaurant Block]]
 +
**[[Builder_Blocks:_Restaurant_-_Example_Customizations|Customization Examples]]
 +
*[[Builder_Church_Block:_Customizations|Builder Church Block]]
 +
**[[Builder_Blocks:_Church_-_Example_Customizations|Customization Examples]]
 +
*[[Builder_Events_Block:_Customizations|Builder Events Block]]
 +
**[[Builder_Blocks:_Events_-_Example_Customizations|Customization Examples]]
 +
*Builder Audio Block
 +
**[[Builder_Blocks:_Audio_-_Example_Customizations|Customization Examples]]

Revision as of 09:33, July 30, 2013

How to assign a layout to Events listing page

Add this code at the end of active theme's (child theme of Builder) functions.php:

function custom_filter_events_layout( $layout_id ) {
    if ( is_post_type_archive('it_bb_event') )
            return '4e57b7c528e6e';
    
    return $layout_id;
}
add_filter( 'builder_filter_current_layout', 'custom_filter_events_layout' );

In the above, change "4e57b7c528e6e" to the ID of layout that you wish to assign to Events archive page.

To find the ID for a Layout, go to the Layouts listing, copy the edit link for the desired Layout, paste the link somewhere, and grab the text after the last equal sign. For example, consider the following link:

http://example.com/wp-admin/admin.php?page=layout-editor&editor_tab=layouts&layout=4e57b7c528e6e

The Layout's ID for the above is 4e57b7c528e6e.

How to add start and end date and location to list of events

Note, this applies to the WordPress backend, see image:

BB events list.jpg

Add the following code at the end of your child theme's functions.php file, but before the closing ?> (if any).

// Add fields to events columns
add_filter('manage_edit-it_bb_event_columns', 'my_it_bb_event_columns');
function my_it_bb_event_columns( $it_bb_event_columns ) {
 
    $new_columns['cb'] = '<input type="checkbox" />';
    $new_columns['title'] = __('Event Name', 'column name');
    $new_columns['event_start_date'] = _x('Start Date');
    $new_columns['event_end_date'] = _x('End Date');
    $new_columns['event_address'] = __('Location', 'event_address');
//    $new_columns['author'] = __('Author');  uncomment to show author
//    $new_columns['date'] = _x('Date Created', 'column name');  uncomment to show creation date
 
    return $new_columns;
}

// Get fields for events columns
add_action('manage_it_bb_event_posts_custom_column', 'my_it_bb_event_custom__columns', 10, 2);
function my_it_bb_event_custom__columns( $column_name, $id ) {
    
    $event_data = get_post_meta( $id , '_it_options' , true ) ;
        
    switch ($column_name) {
        
    // event start date
    case 'event_start_date':
        if ( $event_data[$column_name] )
            echo date_i18n( get_option( 'date_format' ) , strtotime( $event_data[$column_name] ) );
        
        break;
    // event end date        
    case 'event_end_date':
        if ( $event_data[$column_name] )
            echo date_i18n( get_option( 'date_format' ) , strtotime( $event_data[$column_name] ) );
        
        break;
        
    // event address, custom or venue
    case 'event_address':
 
        if ( ( !empty ( $event_data['default_location'] ) ) && ( ( $event_data['default_location'] !== 'custom' ) ) )  
            $event_data = get_post_meta( intval( $event_data['default_location'] ) , '_it_options' , true ) ;

        echo nl2br( $event_data[$column_name] );
        
        break;

    default:

        break;
    }
    
    return;
}

// add custom fields to be sortable
add_filter( 'manage_edit-it_bb_event_sortable_columns', 'my_sortable_it_bb_event_columns' );
function my_sortable_it_bb_event_columns( $columns ) {
    
    $columns['event_start_date'] = 'event_start_date';
    $columns['event_end_date'] = 'event_end_date';
    $columns['event_address'] = 'event_address';

    return $columns;
}

See also

Personal tools
Namespaces
Variants
Actions
iThemes Codex
Codex Navigation
Toolbox