View Single Post
  #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>