Forum

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search:

— Forum Scope —



— Match —



— Forum Options —




Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 3 characters - maximum search word length is 84 characters

Topic RSS
Search Filter in Sidebar
8 September, 2011
10:19 pm
hughbo
Member
Forum Posts: 5
Member Since:
22 January, 2011
Offline

Hi,

I'd like to use the search filter in the sidebar.

Is it possible to use this in a Wordpress template?
sb_print_filters();
If so, what arguments would need to go in it?

Or, is there a way to use the [filters_form] shortcode in the sidebar?

If it's possible, is there an easy way to change the filter form layout / fields etc. ?

*FEATURE REQUEST*
Is this a possibility for future development?
To be able to search by Preacher, Series, and Book from a Widget would be awesome.

Thanks very much if you can help.

Hugh Bourne
bhmc.org.uk

Ps. old friends of Nat Ayling – small world!

9 September, 2011
12:49 am
hughbo
Member
Forum Posts: 5
Member Since:
22 January, 2011
Offline

Ok…

Problem solved.
Hacked code from frontend.php that controls drop-down filter to perform same job in sidebar. It's hardcoded into the template file.

If anyone has the knowledge to do the same, but as a nice tidy widget that would be very nice.

Thanks.

http://www.bhmc.org.uk/sermons/

9 September, 2011
3:40 am
Rich Brown
Parkville, MD
Guru
Forum Posts: 306
Member Since:
13 July, 2009
Offline

That looks fantastic.

Rich Brown
Aisquith Presbyterian Church
Parkville, Maryland, USA
sermons.aisquith.org
13 September, 2011
2:42 pm
stevepalf
New Member
Forum Posts: 1
Member Since:
13 September, 2011
Offline

The sidebar search looks great.

Noddy question – how did you get the filter button to say 'search' instead – is the code for that in the frontend.php file too?

28 September, 2011
6:11 am
thedebolavirus
Sydney, Australia
Enthusiast
Forum Posts: 15
Member Since:
1 November, 2010
Offline

That looks great. I'm in the process of customising a sermons sidebar too. What changes did you make to frontend.php to get it to work?

4 October, 2011
10:50 pm
hughbo
Member
Forum Posts: 5
Member Since:
22 January, 2011
Offline

Hello folks.

Sorry for the delay, I was out of the country for a while after sorting this.
The process to create this involved creating a template page for the sermon page. I've included the code below for the sidebar element of the template, so take your standard page template and replace the sidebar section with this code – I also included a dynamic sidebar for the other widgets that aren't hardcoded into the template file.

I'm sure I did, but I can't remember any major changes made to the plugin files, essentially this code is just ripped from the frontend.php file.

Hope this is helpful. I don't check this often, you can try me at hughbo AT gmail.com for help, no promises.
Thanks

<div id="sidebar" class="clearfix">

<div id="sermon-search" class="widget sidebar-block sermon-search"><h3 class="widgettitle">Search Sermons</h3>
<?php
// Drop-down filter
$preachers = $wpdb->get_results("SELECT p.*, count(p.id) AS count FROM {$wpdb->prefix}sb_preachers AS p JOIN {$wpdb->prefix}sb_sermons AS s ON p.id = s.preacher_id GROUP BY p.id ORDER BY count DESC, s.datetime DESC");
$series = $wpdb->get_results("SELECT ss.*, count(ss.id) AS count FROM {$wpdb->prefix}sb_series AS ss JOIN {$wpdb->prefix}sb_sermons AS sermons ON ss.id = sermons.series_id GROUP BY ss.id ORDER BY sermons.datetime DESC");
$services = $wpdb->get_results("SELECT s.*, count(s.id) AS count FROM {$wpdb->prefix}sb_services AS s JOIN {$wpdb->prefix}sb_sermons AS sermons ON s.id = sermons.service_id GROUP BY s.id ORDER BY count DESC");
$book_count = $wpdb->get_results("SELECT bs.book_name AS name, count(distinct bs.sermon_id) AS count FROM {$wpdb->prefix}sb_books_sermons AS bs JOIN {$wpdb->prefix}sb_books AS b ON bs.book_name = b.name GROUP BY b.id");
$sb = array(
'Title' => 'm.title',
'Preacher' => 'preacher',
'Date' => 'm.datetime',
'Passage' => 'b.id',
);
$di = array(
'Ascending' => 'asc',
'Descending' => 'desc',
);
$csb = isset($_REQUEST['sortby']) ? $_REQUEST['sortby'] : 'm.datetime';
$cd = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : 'desc';
?>
<span class="inline_controls"><a href="#" id="show_hide_filter"></a></span>
<div id="mainfilter">
<form method="post" id="sermon-filter" action="<?php echo sb_display_url(); ?>">
<div style="clear:both">
<table class="sermon-search">
<tr>
<td class="fieldname"><?php _e('Preacher', $sermon_domain) ?></td>
<td class="field"><select name="preacher" id="preacher">
<option value="0" <?php echo (isset($_REQUEST['preacher']) && $_REQUEST['preacher'] != 0) ? '' : 'selected="selected"' ?>><?php _e('[All]', $sermon_domain) ?></option>
<?php foreach ($preachers as $preacher): ?>
<option value="<?php echo $preacher->id ?>" <?php echo isset($_REQUEST['preacher']) && $_REQUEST['preacher'] == $preacher->id ? 'selected="selected"' : '' ?>><?php echo stripslashes($preacher->name).' ('.$preacher->count.')' ?></option>
<?php endforeach ?>
</select>
</td>
</tr>
<tr>
<td class="fieldname"><?php _e('Book', $sermon_domain) ?></td>
<td class="field"><select name="book">
<option value=""><?php _e('[All]', $sermon_domain) ?></option>
<?php foreach ($book_count as $book): ?>
<option value="<?php echo $book->name ?>" <?php echo isset($_REQUEST['book']) && $_REQUEST['book'] == $book->name ? 'selected=selected' : '' ?>><?php echo stripslashes($book->name). ' ('.$book->count.')' ?></option>
<?php endforeach ?>
</select>
</td>
</tr>
<tr>
<td class="fieldname"><?php _e('Series', $sermon_domain) ?></td>
<td class="field"><select name="series" id="series">
<option value="0" <?php echo (isset($_REQUEST['series']) && $_REQUEST['series'] != 0) ? '' : 'selected="selected"' ?>><?php _e('[All]', $sermon_domain) ?></option>
<?php foreach ($series as $item): ?>
<option value="<?php echo $item->id ?>" <?php echo isset($_REQUEST['series']) && $_REQUEST['series'] == $item->id ? 'selected="selected"' : '' ?>><?php echo stripslashes($item->name).' ('.$item->count.')' ?></option>
<?php endforeach ?>
</select>
</td>
</tr>
<tr>
<td class="fieldname"><?php _e('Keywords', $sermon_domain) ?></td>
<td class="field" colspan="3"><input style="width: 50%" type="text" id="title" name="title" value="<?php echo isset($_REQUEST['title']) ? mysql_real_escape_string($_REQUEST['title']) : '' ?>" /></td>
</tr>
<tr>
<td colspan="1"></td>
<td class="field"><input type="submit" class="filter" value="<?php _e('Search', $sermon_domain) ?>"></td>
</tr>
</table>
<input type="hidden" name="page" value="1">
</div>
</form>
</div>
<script type="text/javascript">
jQuery.datePicker.setDateFormat('ymd','-');
jQuery('#date').datePicker({startDate:'01/01/1970'});
jQuery('#enddate').datePicker({startDate:'01/01/1970'});
<?php if ($hide_filter === TRUE) { ?>
jQuery(document).ready(function() {
<?php echo $js_hide; ?>
});
<?php } ?>
</script>

</div>
</div>

5 October, 2011
12:26 am
thedebolavirus
Sydney, Australia
Enthusiast
Forum Posts: 15
Member Since:
1 November, 2010
Offline

It worked! All I had to do was cut and paste the code into my custom sidebar and change the width of the search fields so they didn't extend beyond the page. Thank you so much.

5 October, 2011
1:50 pm
xrstokes
Australia
Enthusiast
Forum Posts: 19
Member Since:
30 September, 2011
Offline

I hate to ask. But "creating a template page for the sermon page". Embarrassingly, I need more info. Does it belong in style.css or sidebar.php or something totally different. I use a custom theme for that page already.

Thanks in advance.

I Love People. I Love Jesus. But most of all. I Love telling People about Jesus.
6 October, 2011
12:50 am
xrstokes
Australia
Enthusiast
Forum Posts: 19
Member Since:
30 September, 2011
Offline

Don't worry. i put it in sidebar.php and it seems to be working. just let me know if that's the wrong thing to do.

Thanks

I Love People. I Love Jesus. But most of all. I Love telling People about Jesus.
6 October, 2011
3:29 am
thedebolavirus
Sydney, Australia
Enthusiast
Forum Posts: 15
Member Since:
1 November, 2010
Offline
10

That's right. If you want the search form appearing in all your sidebars then you've done the right thing. It's only if you want a custom sidebar for the sermon page that you'll need to make a custom template for the sermon page (so you can request your custom sidebar on that page only).

7 October, 2011
6:40 am
xrstokes
Australia
Enthusiast
Forum Posts: 19
Member Since:
30 September, 2011
Offline

Ok, I've got it working in IE9 by putting it in sidebar default.php but it doesn't work on the ipad or in chrome. I think it's a z-index problem. I can see it but it seems like it's behind glass. any idea's.

I Love People. I Love Jesus. But most of all. I Love telling People about Jesus.
7 October, 2011
12:53 pm
thedebolavirus
Sydney, Australia
Enthusiast
Forum Posts: 15
Member Since:
1 November, 2010
Offline
12

That's weird. Have you got a link so we can check it out?

7 October, 2011
1:07 pm
xrstokes
Australia
Enthusiast
Forum Posts: 19
Member Since:
30 September, 2011
Offline
13

Thanks for the response. I just figured it out 10seconds ago.
Doh! Totally my fault. A few days back i tryed to get a bit fancy with my css and ended up with an invisible floating object. So embarrasing. the link is http://www.cocwarragul.com.au . Our sermons are already available through itunes store or by RSS but the site is in maintance mode while I'm working on it. Do these little upgrades always end up taking 3 times longer then you think. Or is it just cause i'm new at it. Please tell me it gets easier.

I Love People. I Love Jesus. But most of all. I Love telling People about Jesus.
8 October, 2011
12:17 am
thedebolavirus
Sydney, Australia
Enthusiast
Forum Posts: 15
Member Since:
1 November, 2010
Offline
14

LOL! It does!

Forum Timezone: Europe/London

Most Users Ever Online: 40

Currently Online:
18 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

malpan: 2453

jogen: 2440

VanWatterson: 652

GeraldSebring: 364

LucasWoltman: 362

RandellFeenstra: 362

Member Stats:

Guest Posters: 7

Members: 2066

Moderators: 1

Admins: 1

Forum Stats:

Groups: 1

Forums: 2

Topics: 1071

Posts: 4045

Newest Members: Nixon Designs, zolaperry, tanec69, lbakyl, richdorm, Aaron Velasquez

Moderators: Ben Miller (387)

Administrators: Mark Barnes (425)

Comments are closed.