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 October 8th, 2012, 03:35 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default Add a category drop down menu to the Advanced Search

Here's how to add a drop down menu with your categories to the Advanced Search widget.

1. Go here: The Factory > Your Store > VIEWS > WIDGETS > Advanced Search

2. Delete the Text module that already is in the view.

3. Add a new Category list module to the view.

4. Add the following code to the Category list module:

HTML Code:
[search.form]
<div class="store_search_form">

	<p class="keyword"><label for="word">Keyword</label> [search.word]</p>
	
	<p class="merchant"><label for="merchant">Merchant</label> [search.merchant]</p>
	
	<p class="tag"><label for="tags">Tags</label> [search.tags]</p>
	
	<p class="price"><label for="price">Price</label> [search.selectprice options='any, cheap(-5), $5 - $10, $10 - $20, more than 20 (20+)']</p>
	
	<p class="category">
		<label for="category">Category</label> 
		<select name="c">
			[category.list before='' after='']
				<option value="[category.id]"><?php echo str_repeat ('-', (($depth-1)*2) ); ?> &nbsp; [category.name]</option>
				[category.repeat]
			[/category.list]
		</select>
	</p>
	
	<p class="button">[search.submit title='Find it!']</p>
	
</div>
[/search.form]
5. Save.

After you click the [Update Settings Only] button on your site, your Advanced Search widget will now have a drop down menu containing your categories.

Eric
  #2  
Old October 28th, 2012, 04:10 AM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

Store ID: 16iizsa3ku6mhoje
Website URL: http://www.paardenlifestyle.com/store

Hi Eric,

thanks for posting that. It has been a bit quiet in my shop the last two weeks; I'd figured I had to contact the merchants and try to make sure they fill out brand and the appropriate tag, because it has been a lot of work for me. So I'm in the middle of doing that. I did make a bit of money in last month (almost €200!). I think that's quite good since I only started in september. I'm doing very well in Google, but that's probably because I have a blog attached to it.

Anyway, my question. I have a drop down for merchant and brand which works great. Now I was wondering how to include the dropdown menu for categories since my drop down code is a bit different and I'm not using the widget (since I attach specific ID's to the filters).

The code I have it as follows (for the page http://www.paardenlifestyle.com/stor.../bovenkleding/ )



HTML:

<form method="get">
<p style="font-family: Play; font-size: 18px; margin-bottom: 10px;">Selecteer merk</p><select name="brand">
<?php echo dfr_get_brands('991838,991938,992029,992447'); ?>
</select>

<p style="font-family: Play; font-size: 18px; margin-bottom: 10px; margin-top: 10px;">Selecteer webshop</p><select name="merchant_id">
<?php echo dfr_get_merchants('991838,991938,992029,992447'); ?>
</select>
<p style="margin-bottom: 20px;"></p>
<input type="submit" value="Zoeken" />

</form>



functions.php :

function dfr_get_brands($cat=false) {
global $wpdb;
if ($cat) { $cat_query = "WHERE p2c.cat_id IN (".$cat.") "; }
$brands = $wpdb->get_results("
SELECT brand, p2c.cat_id
FROM ".$wpdb->prefix."dfr_shop_products AS p
INNER JOIN ".$wpdb->prefix."dfr_shop_p2c AS p2c ON p.id = p2c.id
$cat_query
GROUP BY brand
");
$html = '<option value="">Alle merken</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;
}

function dfr_get_merchants($cat=false) {
global $wpdb;
if ($cat) { $cat_query = "WHERE p2c.cat_id IN (".$cat.") "; }
$merchants = $wpdb->get_results("
SELECT merchant, merchant_id, p2c.cat_id
FROM ".$wpdb->prefix."dfr_shop_products AS p
INNER JOIN ".$wpdb->prefix."dfr_shop_p2c AS p2c ON p.id = p2c.id
$cat_query
GROUP BY merchant
");
$html = '<option value="">Alle webshops</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>';
}
}
return $html;
}

How do I add the dropdown for categories? I'm assuming I have to fill out the ID's for the categories I want to show up in the filter for certain pages? In this example I would only want to show the categories from the IDs 991838, 991938, 992029 and 992447.

When I simply add the code you've shown to the HTML (the category filter), it doesn't show the categories, just an empty dropdown.

I hope you can help me out Thanks in advance!

Best regards,

Conny
  #3  
Old October 28th, 2012, 09:32 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi Conny,

Congrats on your success. To add a category drop down with those 4 categories to your form, you should change your form to something like this:

HTML Code:
<form method="get">
<p style="font-family: Play; font-size: 18px; margin-bottom: 10px;">Selecteer merk</p><select name="brand">
<?php echo dfr_get_brands('991838,991938,992029,992447'); ?>
</select>

<p style="font-family: Play; font-size: 18px; margin-bottom: 10px; margin-top: 10px;">Selecteer webshop</p><select name="merchant_id">
<?php echo dfr_get_merchants('991838,991938,992029,992447'); ?>
</select>

<p style="font-family: Play; font-size: 18px; margin-bottom: 10px;">Category</p><select name="c">
	<option value="991838">Jassen</option>
	<option value="991938">Bodywarmers</option>
	<option value="992029">Vesten1</option>
	<option value="992447">Shirts1</option>
</select>

<p style="margin-bottom: 20px;"></p>
<input type="submit" value="Zoeken" />

</form>
Eric
  #4  
Old October 28th, 2012, 10:11 AM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

wow that worked great!!

I'm now redesigning the pages to make the filters next to each other, but wordpress keeps adding line breaks. Anyway, thanks for your quick reply!!!!
 


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
Change width of drop down menu fsuggest Questions 4 April 29th, 2012 10:40 AM
Need help on Drop down Menu for Brand filter jdrom Questions 3 March 29th, 2012 07:17 PM
Best way for drop dawn main menu? barbinec Questions 1 February 8th, 2012 08:42 AM
drop down menu Papada Questions 1 January 4th, 2012 02:24 PM
No drop down menu in new factory marcaustin Problems 15 March 10th, 2011 02:36 PM


All times are GMT -5. The time now is 05:50 PM.


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