Datafeedr Support Forums

Datafeedr Support Forums (/index.php)
-   Questions (/forumdisplay.php?f=67)
-   -   search bar searching by tag instead of title (/showthread.php?t=11462)

yankeestonk January 20th, 2015 10:28 AM

search bar searching by tag instead of title
 
http://saveongolf.net
saveongolfcopy is the store

I just realized my main search bar is searching by tag rather than title or description. I forgot how to change that. Somewhere in the redesign it must have been switched. A search for "Titleist" for instance grabs all sorts of results from companies that for some unknown reason put other manufacturer names in their tags.

This is the code I'm looking at for simple search

<script type="text/javascript">
<!--
/*
* NOTE: This JS code would be much better off
* existing in your theme's header.php file.
*/
function wash( anInput ) { if(anInput.value == anInput.defaultValue) anInput.value = ''; }
function checkWash( anInput ) { if(anInput.value == '') anInput.value = anInput.defaultValue; }
//-->
</script>

<div class="store_search_form">
[search.form]
[search.name onfocus='wash(this);' onblur='checkWash(this);' value='Refine search...']
[search.submit title='Go']
<input type="checkbox" name="saleprice" value="1-" />On Sale
[/search.form]
</div>


...and this is the code in the widget area of my wordpress site!

<form role="search" method="get" id="searchform" class="search-form" action="/store/search/">
<div><label class="screen-reader-text" for="s">Search for:</label>
<input class="search-field" type="text" name="word" id="s" value="<?php echo esc_attr( @$_GET['word'] ); ?>">
<input class="search-submit" type="submit" id="searchsubmit" value="Search"><input name="saleprice" value="1-" type="checkbox"><strong style="color:#fff;margin-top: 5px; display: inline-table; margin-left: 5px; float: left;">On sale</strong>
</div></form>


Thanks!
ken

Eric January 20th, 2015 10:45 AM

Hi

Both of those search forms are searching title, description and tag fields.

Eric

yankeestonk January 20th, 2015 10:50 AM

Can you show me how to get rid of the search by tag from both?

Eric January 20th, 2015 10:56 AM

Hi

That's not possible. The "word" tag searches those 3 fields. If you want, you can change "word" to "name" to only search the product names.

Replace all occurrences of name="word" with name="name".

Eric

yankeestonk January 20th, 2015 11:00 AM

I only see the one, does the below look correct to you? The one I'd be changing is the one in wordress widget. Also, can it search both title and description for name. I'm not sure if that's what you meant by not possible.

<script type="text/javascript">
<!--
/*
* NOTE: This JS code would be much better off
* existing in your theme's header.php file.
*/
function wash( anInput ) { if(anInput.value == anInput.defaultValue) anInput.value = ''; }
function checkWash( anInput ) { if(anInput.value == '') anInput.value = anInput.defaultValue; }
//-->
</script>

<div class="store_search_form">
[search.form]
[search.name onfocus='wash(this);' onblur='checkWash(this);' value='Refine search...']
[search.submit title='Go']
<input type="checkbox" name="saleprice" value="1-" />On Sale
[/search.form]
</div>


...and this is the code in the widget area of my wordpress site!

<form role="search" method="get" id="searchform" class="search-form" action="/store/search/">
<div><label class="screen-reader-text" for="s">Search for:</label>
<input class="search-field" type="text" name="name" id="s" value="<?php echo esc_attr( @$_GET['word'] ); ?>">
<input class="search-submit" type="submit" id="searchsubmit" value="Search"><input name="saleprice" value="1-" type="checkbox"><strong style="color:#fff;margin-top: 5px; display: inline-table; margin-left: 5px; float: left;">On sale</strong>
</div></form>

Eric January 20th, 2015 11:04 AM

If you use name="name", then the search will ONLY search the products' names.

If you use name="word", the the search will search the products' names, descriptions AND tags.

yankeestonk January 20th, 2015 11:13 AM

Ok, thanks. Is the code above right? I ask because you said "replace all instances of name="word" ... I only found one. Is that code above right?

Eric January 20th, 2015 11:24 AM

Looks fine to me but I haven't tested it. There should only be one occurrence of that line.

yankeestonk January 20th, 2015 11:25 AM

ok I'm going in! Thanks.

yankeestonk January 20th, 2015 11:40 AM

it worked! Thanks so much again.

Eric January 20th, 2015 11:42 AM

Great! You're welcome!


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

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