Datafeedr Support Forums  

Go Back   Datafeedr Support Forums > Current Version (V3) Forum > Questions
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
  #21  
Old January 18th, 2012, 06:05 AM
meinehandtasche meinehandtasche is offline
 
Join Date: Jul 2011
Posts: 43
Default

Store ID: 32722
Website URL: http://www.meinehandtasche.de/
URL to page in question: http://www.meinehandtasche.de/store/


Thank you Eric,

that worked. To exclude brands from the list was too much work, therefore I did it the way around to make a list of brands that are allowed. To do so I have changed your code from
Quote:
WHERE brand NOT IN
to
Quote:
WHERE brand IN
.

It works just fine now :-) Thanks again!!

Here my full code pasted into the functions.php file of my theme template:
Quote:
function dfr_get_brands() {
global $wpdb;
$brands = $wpdb->get_results("SELECT brand FROM ".$wpdb->prefix."dfr_shop_products
WHERE brand IN('ABACO','ABRO','AIGNER')
GROUP BY brand");
$html = '';
foreach ($brands as $brands) {
$html .= '<option value="'.$brands->brand.'">'.ucwords($brands->brand).'</option>';
}
return $html;
}
And now to wrap up this kind of little how-to:

I pasted the following code into / Factory > Widgets > add a new widget / and then used / category list / from the available widget view modules:

Brands:<br />
<form method="get">
<select name="brand">
<?php echo dfr_get_brands(); ?>
<input type="submit" value="GO" />
</select>
</form>

One thing I couldn't solve: if there are brands having some kind of special characters like "TOD'S" caused problems - the list couldn't be displayed. This character ' is used to separate one brand from the other therefore I had to kick out all brands containing this character.
Is there maybe a solution for that as well?


Now I am working on a price filter as drop down that works together with the drop down brand filter.
Currently I just use the following which works perfectly but it would be much nicer to have a drop down:

Paste this into / Factory > Widgets > add a new widget / OR into the same widget as the brand filter widget mentioned above. I have use / text / from the available widget view modules:
Quote:
<br />
Prices:
<ul>
<?php if (@$_GET['price']) { ?>

<li><a href="[server.url type='fullpage' query='-price']">[X] delete price filter</a></li>

<?php } else { ?>

<li><a href="[server.url type='fullpage' query='price=-50']">< 50</a></li>
<li><a href="[server.url type='fullpage' query='price=50-100']"> 50 - 100</a></li>
<li><a href="[server.url type='fullpage' query='price=100-150']"> 100 - 150</a></li>
<li><a href="[server.url type='fullpage' query='price=150-250']"> 150 - 250</a></li>
<li><a href="[server.url type='fullpage' query='price=250-500']"> 250 - 500</a></li>
<li><a href="[server.url type='fullpage' query='price=500-1000']"> 500 - 1.000</a></li>
<li><a href="[server.url type='fullpage' query='price=1000-']">> 1.000</a></li>

<?php } ?>
</ul>
  #22  
Old January 18th, 2012, 08:32 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi
Quote:
Originally Posted by meinehandtasche View Post
One thing I couldn't solve: if there are brands having some kind of special characters like "TOD'S" caused problems - the list couldn't be displayed. This character ' is used to separate one brand from the other therefore I had to kick out all brands containing this character.
Is there maybe a solution for that as well?
You need to escape the single quotes like this: 'TOD\'S'

Quote:
Originally Posted by meinehandtasche View Post
Now I am working on a price filter as drop down that works together with the drop down brand filter.
Currently I just use the following which works perfectly but it would be much nicer to have a drop down:
This is not related to the brand filter and should be posted in a new thread.

Eric
  #23  
Old March 17th, 2012, 09:09 AM
lesljr lesljr is offline
 
Join Date: Jan 2012
Posts: 80
Default

how do i use the code to set a dynamic filter without the drop drop down. I want it to look like the filter by price with the url. I know I need to change $html to

$html .= <li><a href="URL_QUERY">'.ucwords($brands->brand).'</a></li>

but I'm not sure of the syntax for the url.

Quote:
Originally Posted by Eric View Post
Here's an example of how to remove brands from the list. I've removed 'Adidas' and 'Atlas'. This example also shows how to capitalize the first letter in each word of the brand.
PHP Code:
function dfr_get_brands() {
    global 
$wpdb;
    
$brands $wpdb->get_results("SELECT brand FROM ".$wpdb->prefix."dfr_shop_products 
    WHERE brand NOT IN('Adidas','Atlas') 
    GROUP BY brand"
);
    
$html '';
    foreach (
$brands as $brands) {
        
$html .= '<option value="'.$brands->brand.'">'.ucwords($brands->brand).'</option>';
    }
    return 
$html;

  #24  
Old March 17th, 2012, 10:01 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Quote:
Originally Posted by lesljr View Post
how do i use the code to set a dynamic filter without the drop drop down. I want it to look like the filter by price with the url.
Here's the PHP:
PHP Code:
function dfr_get_brands() {
    global 
$wpdb;
    
$brands $wpdb->get_results("SELECT brand FROM ".$wpdb->prefix."dfr_shop_products GROUP BY brand");
    
$list = array(); 
    foreach (
$brands as $brands) {
        
$list[] = $brands->brand
    }
    return 
$list

And in your views:
HTML Code:
<ul> 
<?php 
$brands = dfr_get_brands(); 
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>
  #25  
Old March 17th, 2012, 11:12 PM
lesljr lesljr is offline
 
Join Date: Jan 2012
Posts: 80
Default

Store ID: 35889
Website URL:
URL to page in question: http://autotulsablog.com/store/category/car-stereos/

this didn't work. what am I doing wrong?
  #26  
Old March 18th, 2012, 08:41 AM
lesljr lesljr is offline
 
Join Date: Jan 2012
Posts: 80
Default

I copied everything in, but it doesn't display any brands. how do i figure out whether the function is wrong or the widget view is wrong?
  #27  
Old March 18th, 2012, 09:31 AM
lesljr lesljr is offline
 
Join Date: Jan 2012
Posts: 80
Default

i turned on debug, and it said i made a call to a undefined function. I copied the php code to my function.php file. why can't it find the function?
  #28  
Old March 18th, 2012, 09:56 AM
lesljr lesljr is offline
 
Join Date: Jan 2012
Posts: 80
Default

FATAL(msg) view=widget err=Fatal error</b>: Call to undefined function dfr_get_brands()
  #29  
Old March 18th, 2012, 10:00 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Quote:
Originally Posted by lesljr View Post
i turned on debug, and it said i made a call to a undefined function. I copied the php code to my function.php file. why can't it find the function?
What is the path of the functions.php file that you modified?
  #30  
Old March 18th, 2012, 10:13 AM
lesljr lesljr is offline
 
Join Date: Jan 2012
Posts: 80
Default

not sure of the path. I get to it by going to appearance and editor. then changing the functions.php for my theme
  #31  
Old March 18th, 2012, 10:43 AM
lesljr lesljr is offline
 
Join Date: Jan 2012
Posts: 80
Default

do I need to add it to datafeedr.php or is there a way to set the path?

Last edited by lesljr : March 18th, 2012 at 10:46 AM.
  #32  
Old March 18th, 2012, 11:27 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Quote:
Originally Posted by lesljr View Post
not sure of the path. I get to it by going to appearance and editor. then changing the functions.php for my theme
That sounds right... Are you sure the file is being saved properly?

The error you are getting is a result of the dfr_get_brands() function not being properly saved in the functions.php file.
  #33  
Old March 18th, 2012, 11:33 AM
lesljr lesljr is offline
 
Join Date: Jan 2012
Posts: 80
Default

here is what the functions.php file looks like

<?php
/* This is the main function.php override file - it controls most of the stuff happening with the theme */

/* Anything you need to actively do, put here. This is the first code that will get run whenever the
child theme is activated and used. This example just re-defines a function, but you could do anything.
*/

function weaver_continue_reading_link() {
/* very simple example - override the read more text... */

$msg = '[CLICK TO READ MORE]';
return ' <a class="more-link" href="'. get_permalink() . '">' . $msg . '</a>';
}

function dfr_get_brands() {
global $wpdb;
$brands = $wpdb->get_results("SELECT brand FROM ".$wpdb->prefix."dfr_shop_products GROUP BY brand");
$list = array();
foreach ($brands as $brands) {
$list[] = $brands->brand;
}
return $list;
}

?>
  #34  
Old March 18th, 2012, 11:44 AM
lesljr lesljr is offline
 
Join Date: Jan 2012
Posts: 80
Default

if i copy the code to datafeedr.php, it works. so it looks like it is a path problem.
  #35  
Old March 18th, 2012, 11:49 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Quote:
Originally Posted by lesljr View Post
if i copy the code to datafeedr.php, it works. so it looks like it is a path problem.
If you want to put it there, that will work but it will be lost everytime you upgrade the Datafeedr plugin.

Try adding the code to the end of the functions.php file which exists here:

/wp-content/themes/weaver-ii-pro/

I have a feeling you're adding the code to the wrong file.

Eric
  #36  
Old July 17th, 2012, 02:44 AM
asperty asperty is offline
 
Join Date: Jul 2012
Posts: 4
Default

Eric,

With regards the above dropdown brand filter,

is it possible to have the first entry in the drop down "select" rather than the name of the first brand?

BTW
Thanks for the info and support.

I have only been around for a few days and already I love datafeedr
  #37  
Old July 17th, 2012, 06:34 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi
Quote:
Originally Posted by asperty View Post
is it possible to have the first entry in the drop down "select" rather than the name of the first brand?
Yes, that's how I did it in my example here: http://www.datafeedr.com/forums/showthread.php?t=6778

Eric
  #38  
Old July 17th, 2012, 07:53 AM
asperty asperty is offline
 
Join Date: Jul 2012
Posts: 4
Default

Thanks for the magic Eric
  #39  
Old June 20th, 2013, 03:03 AM
stylifyfashion stylifyfashion is offline
 
Join Date: Jun 2013
Posts: 10
Exclamation Is it possible to create a price filter as well

Store ID: 42001

Hi Eric, I used the brand drop down filter, which works great. Is there any coding (html, and functions.php) for a price filter, and merchant filter, and can a colour filter be created.

Thanks again for the awesome brand filter dropdown.

Last edited by Eric : August 4th, 2013 at 02:09 PM. Reason: Removed website URL.
  #40  
Old June 20th, 2013, 07:56 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Quote:
Originally Posted by stylifyfashion View Post
Store ID: 42001
URL to page in question:

Hi Eric, I used the brand drop down filter, which works great. Is there any coding (html, and functions.php) for a price filter, and merchant filter, and can a colour filter be created.

Thanks again for the awesome brand filter dropdown.
Hi,

Here's one for brands, merchants and networks: http://www.datafeedr.com/forums/showthread.php?t=6778

Here's an example of a price filter:
HTML Code:
	<!-- Price drop down select menu -->  
	<select name="price">
		<option value="0-100">$0 - $100</option>
		<option value="100-500">$100 - $500</option>
		<option value="500-10000">$500 - $10,000</option>
	</select>
Here's an example of a color filter:
HTML Code:
	<!-- Color drop down select menu -->  
	<select name="word">
		<option value="blue">Blue</option>
		<option value="black">Black</option>
		<option value="green">Green</option>
	</select>
Eric

Last edited by Eric : August 4th, 2013 at 02:09 PM. Reason: Removed website URL.
 


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
Merchant and Brand filter Widgets Nugerama Tips, Tricks & Tutorials 13 March 7th, 2012 05:01 PM
Brand Filter Drop-Down with All Brands option meperez Questions 8 March 26th, 2011 12:04 AM
Brand Filter = Brands Only show when in Category macfink Questions 3 March 25th, 2011 12:55 PM
Drop down Menu from filter by Brand macfink Questions 4 March 25th, 2011 09:32 AM
Brand filter? sylviathewitch Problems 3 March 8th, 2011 08:43 AM


All times are GMT -5. The time now is 03:14 AM.


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