Datafeedr Support Forums  

Go Back   Datafeedr Support Forums > Current Version (V3) Forum > Tips, Tricks & Tutorials
Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Important - The support forums are now in "read-only" mode as we transition to an alternative help desk solution. Feel free to contact us here with any of your questions or search the forums for an existing solution.
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old April 18th, 2012, 09:11 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
Join Date: Feb 2008
Posts: 16,902
Default Drop down menus for Brands, Merchants and Networks

Here's how to add a <select> dropdown menu for brands, merchants and networks. If you are not comfortable editing PHP or HTML code, this tutorial might not be for you.

You don't have to use them all but you can if you want. Here's what it will look like:

1. Go here: The Factory > Your Store > VIEWS > WIDGETS > Add a new view

2. Name the view "Drop Down Filters"

3. Add a Text module to the view

4. Add the following code to the Text module:

HTML Code:
<form method="get">
	<!-- Brand drop down select menu -->
	<select name="brand">
		<?php echo dfr_get_brands(); ?>
	<!-- Merchant drop down select menu -->
	<select name="merchant_id">
		<?php echo dfr_get_merchants(); ?>
	<!-- Network drop down select menu -->  
	<select name="net_id">
		<?php echo dfr_get_networks(); ?>
	<input type="submit" value="Go" />
5. Save the view.

6. Open your theme's functions.php file (usually found here: /wp-content/themes/YOUR-THEME/functions.php)

7. Add the following PHP code to the bottom of the file:

PHP Code:
function dfr_get_brands() {
$brands $wpdb->get_results("SELECT brand FROM ".$wpdb->prefix."dfr_shop_products GROUP BY brand");
$html '<option value="">Select a brand</option>';
    foreach (
$brands as $brands) {
        if (
trim($brands->brand) != "") {
$selected = (strip_tags(stripslashes($_GET['brand']))==$brands->brand) ? ' selected="selected"' '';
$html .= '<option value="'.$brands->brand.'"'.$selected.'>'.$brands->brand.'</option>';

dfr_get_merchants() {
$merchants $wpdb->get_results("SELECT merchant, merchant_id FROM ".$wpdb->prefix."dfr_shop_products GROUP BY merchant");
$html '<option value="">Select a merchant</option>';
    foreach (
$merchants as $k => $v) {
        if (
trim($v->merchant) != "") {
$selected = (strip_tags($_GET['merchant_id'])==$v->merchant_id) ? ' selected="selected"' '';
$html .= '<option value="'.$v->merchant_id.'"'.$selected.'>'.$v->merchant.'</option>';

dfr_get_networks() {
$networks $wpdb->get_results("SELECT network, net_id FROM ".$wpdb->prefix."dfr_shop_products GROUP BY net_id");
$html '<option value="">Select a network</option>';
    foreach (
$networks as $k => $v) {
        if (
$v->net_id 0) {
$selected = (strip_tags($_GET['net_id'])==$v->net_id) ? ' selected="selected"' '';
$html .= '<option value="'.$v->net_id.'"'.$selected.'>'.$v->network.'</option>';

8. Save the functions.php file.

9. Add the new "Drop Down Filters" widget to your sidebar here: WordPress Admin Area > Appearance > Widgets

That's it.


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Brand Filter Drop-Down with All Brands option meperez Questions 8 March 26th, 2011 12:04 AM
Add drop down menus for store categories ccgmark Tips, Tricks & Tutorials 13 January 28th, 2011 01:34 PM
Adding 'products per page' and 'sort by' drop down menus to pages lbuilta59 Questions 1 January 27th, 2011 10:36 AM

All times are GMT -5. The time now is 12:51 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.