Beetle blog & news
Keo & Lulu get into shape
The fit and supple amoung us are in for a treat as Keo & Lulu opens its doors with a fantastic launch party this week. Situated in an attractive location, housing new mats and a spanking new website, Plymouth will never be quite the same again.
Beetlebrow has made an attractive and easy to update site for K&L to help them promote and maintain their business. With its usual information there is also an online booking system with a payment gateway so that courses can be booked straight from the sofa.
Keo & Lulu are very excited about their new business and also the new branding and website, with its social networking plugins the site will be positively humming.
And now relax...
Under canvas in Salcombe-Regis
Beetlebrow has been invited to take over the reins of this lively camping and caravan web site on the Devon coast. Migrating and hosting the Wordpress site has been successful and we're now in partnership to improve the offering with some ideas we have in our rucksack.
Carry on...
Wordpress Event Manager plugin - adding custom event attribute
How to add an new Event Attribute Teacher to the events page and make it searchable.
I added the new attribute "Teacher" with allowed values "Abi" and "Lou" to the EM Events listing and single event pages. This bit is straight forward so not much detail required...
- First add the new attribute and its allowed values with
Events | Settings | General
Event Attributes : #_ATT{teacher}{Abi|Lou}
It can now be added to events.
- Next add the attribute (and appropriate headings) to the templates in
Settings | Formatting | Events.
Both the default event list and Singel Event page templates were tweaked.
It will now be displayed in Events.
Here's the meat. How to use this new attribute in the EM search form. Customise as you wish. I used the add themes functions.php method...
<?php
...
// START EM Custm Attribute "Teacher" search
/* Create a new search attribute form entry for our new Event Attribute "teacher" (#_ATT{teacher})
The values are hard-coded but could probably be automatically selected
Add this field to the search form using an EM action.
nb. The action doc'd here http://wp-events-plugin.com/tutorials/adding-custom-event-search-form-fields/
does not seem to exist so use the footer one for inclusion in advanced search or the header one
for normal search. Read the source Luke.
*/
function my_teacher_search_field(){ ?>
<div class="em-search-teacher em-search-field">
<label>Teacher</label>
<select name="teacher">
<option value=''>All Teachers</option>
<option value="Abi" <?php echo ((array_key_exists('teacher', $_POST)) && $_POST['teacher'] == "Abi") ? 'selected="selected"':''; ?>>Abi</option>
<option value="Lou" <?php echo ((array_key_exists('teacher', $_POST)) && $_POST['teacher'] == "Lou") ? 'selected="selected"':''; ?>>Lou</option>
</select>
</div>
<?php }
add_action('em_template_events_search_form_footer', 'my_teacher_search_field');
//
/* Hook the new search attribute teacher into default search filter,
so it isn’t ignored when Events Manager creates an events search query
*/
function my_teacher_search($searches, $array){
if( !empty($array['teacher']) ){
$searches['teacher'] = $array['teacher'];
}
return $searches;
}
add_filter('em_events_get_default_search','my_teacher_search',1,2);
/* This isn't needed. It seems that inclusion in the default_search filter
is all thats needed. See http://wp-events-plugin.com/tutorials/adding-custom-event-search-form-fields
*/
//function my_teacher_accepted_searches($searches){
// $searches[] = 'teacher';
// return $searches;
//}
//add_filter('em_accepted_searches','my_teacher_accepted_searches',1,1);
/* Can't hook into em_events_get filter as doc'd here
http://wp-events-plugin.com/tutorials/creating-custom-event-search-attributes/
as we need to join with kal_postmeta and not just filter kal_em_events
so append a subquery via sql_conditions hook to find kal_postmeta using our new search attribute and return valid
posts ids for main event query that is internally appended to display.
*/
function my_teacher_conditions($conditions, $args){
if( !empty($args['teacher'])) {
$teacherval = $args['teacher'];
$conditions['teacher'] = " (kal_em_events.post_id IN ( SELECT post_id FROM kal_postmeta WHERE (kal_postmeta.meta_key = 'teacher' AND kal_postmeta.meta_value = '$teacherval')))";
}
return $conditions;
}
add_filter( 'em_events_build_sql_conditions', 'my_teacher_conditions',1,2);
//
// END EM Custom Attribute Teacher Search
...
?>