Created
August 27, 2013 02:12
-
-
Save zakhardage/6348940 to your computer and use it in GitHub Desktop.
The beginnings of advanced search for Shopify. Using javascript to update the 'type' input field. Using Shopify's search filters (http://wiki.shopify.com/Admin_search#Searching_only_for_certain_types) you can go much further. This could probably be written cleaner/faster, but this is just a quick proof of concept.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form> | |
<h3>Search by type</h3> | |
<input type="checkbox" id="all" onchange="searchType('all')" /> All<br /> | |
<input type="checkbox" id="product" onchange="searchType('product')" /> Product<br /> | |
<input type="checkbox" id="article" onchange="searchType('article')" /> Blog Post<br /> | |
<input type="checkbox" id="page" onchange="searchType('page')" /> Page<br /> | |
</form> | |
<form id="search-form" name="search" action="/search"> | |
<input type="text" id="type" name="type" value="" /> | |
<input type="text" id="q" name="q" value="" class="search replace" title="Search" /> | |
<input type="submit" class="btn" id="search-submit" alt="Search" class="submit" value="Search" /> | |
</form> | |
<script type="text/javascript"> | |
function searchType(type) { | |
if(type=='all') { | |
document.getElementById('product').checked=false; | |
document.getElementById('article').checked=false; | |
document.getElementById('page').checked=false; | |
document.getElementById('type').value=''; | |
} else { | |
document.getElementById('all').checked=''; | |
var product = document.getElementById('product').checked; | |
var article = document.getElementById('article').checked; | |
var page = document.getElementById('page').checked; | |
if(product==true && article==true && page==true) {document.getElementById('type').value='';} | |
else if(product==true && article==true && page==false) {document.getElementById('type').value='product,article';} | |
else if(product==true && article==false && page==true) {document.getElementById('type').value='product,page';} | |
else if(product==true && article==false && page==false) {document.getElementById('type').value='product';} | |
else if(product==false && article==true && page==true) {document.getElementById('type').value='article,page';} | |
else if(product==false && article==true && page==false) {document.getElementById('type').value='article';} | |
else if(product==false && article==false && page==true) {document.getElementById('type').value='page';} | |
else if(product==false && article==false && page==false) {document.getElementById('type').value='';} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment