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
  #1  
Old July 3rd, 2012, 07:23 AM
camseo camseo is offline
 
Join Date: Jun 2012
Location: Suffolk, UK
Posts: 32
Default Category specific Dropdown filters

Hi Everyone / Eric

My first post. I have 100 or so sites built in WP (feed uploads and manipulation nowhere near as good /easy as dfR) and Affilistore (no longer supported). DatafeedR seems like it could be a real timesaver

Awesome tool applying it to a couple of sites fairtrade-fashion.co.uk and cheapbarbecue.co.uk.

I have implemented the category specific brand filter found in another thread (thanks Eric) - works great...however, i'd like it to be as a dropdown as some categories have 30 or 40 brands which is too long. So how can I make this list code into dropdown code?!?

//add to view//

Code:
<ul> 
<?php 
$brands = dfr_get_brands($category->id); 
foreach ($brands as $brand) {
    if ($brand != "") {
    $brand = urlencode($brand); 
    ?> 
    <li><a href="[server.url type='fullpage' query='brand=$brand']"><?php echo urldecode($brand); ?></a></li>
  <?php } ?>
<?php } ?> 
</ul>

//add to function.php//

Code:
function dfr_get_brands($cat=false) {
    global $wpdb;
    if ($cat) { $cat_query = "WHERE cat_id = ".$cat." "; }
    $brands = $wpdb->get_results("SELECT brand FROM ".$wpdb->prefix."dfr_shop_products ".$cat_query."GROUP BY brand");
    $list = array(); 
    foreach ($brands as $brands) {
        $list[] = $brands->brand; 
    }
    return $list; 
}
Thanks very much

James
  #2  
Old July 3rd, 2012, 09:43 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi James,

Welcome to the forums!

I've posted how to do dropdown menus for merchants and brands here: http://www.datafeedr.com/forums/showthread.php?t=6778

Eric
  #3  
Old July 3rd, 2012, 10:58 AM
camseo camseo is offline
 
Join Date: Jun 2012
Location: Suffolk, UK
Posts: 32
Default Hopefully not a stupid question!

Have reviewed other post re dropdowns - will this give me a dropdown menu with brands specific to category A, category B etc or is this a dropdwon where ALL brands are displayed?

james
  #4  
Old July 3rd, 2012, 11:04 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi

It will get you all brands so you'll need to modify the query like you've done above.

Eric
  #5  
Old July 3rd, 2012, 02:59 PM
camseo camseo is offline
 
Join Date: Jun 2012
Location: Suffolk, UK
Posts: 32
Default Cheers

Ok sorted. TX
  #6  
Old August 28th, 2012, 03:50 PM
marksperl marksperl is offline
 
Join Date: Aug 2012
Posts: 12
Default

Im getting duplication or variance of brand names on the drop down. Is there any way to correct that, or is that due to the merchant's feed

ex.
Spy
Spy Optics
Spy Sunglasses
  #7  
Old August 28th, 2012, 03:51 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi

It's due to the merchant's feed. You can change the product's brand in the Factory but if you have lots of products, that could take some time.

Eric
  #8  
Old September 15th, 2012, 05:28 AM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

Hi,

I tried getting the category specific drop down filter, but it didn't work out. I'm not experienced with this. I tried the following code:

in functions:

function dfr_get_brands($cat=false) {
global $wpdb;
if ($cat) { $cat_query = "WHERE cat_id = ".$cat." "; }
$brands = $wpdb->get_results("SELECT brand FROM ".$wpdb->prefix."dfr_shop_products ".$cat_query."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>';
}
}
return $html;
}

in view:

<form method="get">

<!-- Brand drop down select menu -->
<select name="brand">
<?php echo dfr_get_brands($category->id); ?>
</select>


</select>

<input type="submit" value="Go" />

</form>

I'm still getting all the brands in the shop. Eventually, I want to add merchant and price filter. But first I need to figure out how I get it working for brands. Could you tell me what I'm doing wrong?

Thanks in advance!
  #9  
Old September 15th, 2012, 07:36 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi

Your code works for me. I do see you have an extra closing </select> tag.

Make sure you don't cache your view.

Eric
  #10  
Old September 15th, 2012, 07:58 AM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

Thanks for your quick response. The filter shows and it works, however, it also shows brands that are nog in that specific category.

EDIT: for example on this page: http://www.paardenlifestyle.com/stor...eken/stoffen1/
  #11  
Old September 15th, 2012, 08:02 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Did you turn off caching for that view?
  #12  
Old September 15th, 2012, 08:17 AM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

I pressed on "clear cache" so I guess that should do
  #13  
Old September 15th, 2012, 08:19 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi

You should disable caching the View where your <select> form is. Go to the View menu > View Properties and check the "don't cache this view" checkbox.

Also, make sure you don't have any other function named dfr_get_brands in your functions.php file.

Eric
  #14  
Old September 15th, 2012, 08:42 AM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

Thanks again for the quick reply; that's just amazing I checked the "don't cache this view" and had a look at the functions.php file. However, it still doesn't work...

This is the only code I have in my functions.php:

<?php
require_once (TEMPLATEPATH . '/framework/main.php');

// loclization
$lang = TEMPLATE_PATH . '/lang';
load_theme_textdomain('theme', $lang);
load_theme_textdomain('framework', $lang);


function dfr_get_brands($cat=false) {
global $wpdb;
if ($cat) { $cat_query = "WHERE cat_id = ".$cat." "; }
$brands = $wpdb->get_results("SELECT brand FROM ".$wpdb->prefix."dfr_shop_products ".$cat_query."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>';
}
}
return $html;
}

?>
  #15  
Old September 15th, 2012, 08:52 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi

I still see the "Don't cache this view" unchecked here: http://factory3.datafeedr.com/feeder/view?view=224338

Eric
  #16  
Old September 15th, 2012, 10:56 AM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

ah I thought you meant the category page view. Well, I've checked the "don't cache this view" but it seems not be working. I've updated products and settings, but no changes?

Anything else I should do/try?
  #17  
Old September 15th, 2012, 11:08 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi

It seems you are referencing the wrong widget from your Category Page view. You are referencing: [DFR:widget/drop-down-filter]. That view is empty.

You should be referencing "Category specific brand drop down".

Eric
  #18  
Old September 15th, 2012, 11:19 AM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

Not on the category page view "stoffen1" ?
  #19  
Old September 15th, 2012, 11:25 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi

Try replacing this:
Code:
[DFR:widget/category-specific-brand-drop-down]
With this:
HTML Code:
<form method="get">
  
  <!-- Brand drop down select menu -->
  <select name="brand">
    <?php echo dfr_get_brands($category->id); ?>
  </select>
  
  <input type="submit" value="Go" />
  
</form>
Eric
  #20  
Old September 15th, 2012, 11:55 AM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

I replaced it, but now it doesn't show any brand:

http://www.paardenlifestyle.com/stor...eken/stoffen1/
 


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
Category Menu dropdown works but cannot add non Datafeedr menus gutfeelboy Questions 2 August 15th, 2011 08:49 AM
Search in specific category sylviathewitch Questions 1 March 11th, 2011 11:30 AM
Dropdown Filters Code feri Questions 4 March 6th, 2011 05:32 PM
Drip products to one specific category? onefairworld Tips, Tricks & Tutorials 6 February 19th, 2011 09:24 AM
Drip Specific Category k9marketing Tips, Tricks & Tutorials 1 January 23rd, 2011 12:25 PM


All times are GMT -5. The time now is 09:40 PM.


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