Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

A-Z Dropdown Listings - Helpful Navigation

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 11-13-2006, 03:49 AM
 
QVS QVS is offline
 

Senior Member
  
Join Date: Nov 2004
Posts: 136
 

Default A-Z Dropdown Listings - Helpful Navigation

Ive been having problems with my search on my site not reutrning the correct results and therefore customers have been having trouble trying to find what they need. So i decided i needed a A-Z Dropdown menu which is accessible from all pages. Very much like a site map but in a drop down menu form.

LIVE Example: http://www.qvsdirect.com/home.php

1) Replace this part of the code in <x-cart_directory>/auth.php script:


$smarty->assign("printable", $printable);
$smarty->assign("logout_user", $logout_user);
?>


with:

Code:
$sub = func_query ("SELECT category, categoryid FROM xcart_categories ORDER BY category"); $smarty->assign("sub", $sub); $smarty->assign("printable", $printable); $smarty->assign("logout_user", $logout_user); ?>

2) Next open this template file <x-cart_directory>/skin1/customer/home.tpl and insert the JS code below after for example:

{ include file="meta.tpl" }
<LINK rel="stylesheet" href="{$SkinDir}/{#CSSFile#}">

Code:
{literal} <script type="text/javascript"> <!-- function nav() { var w = document.form.list.selectedIndex; var url_add = document.form.list.options[w].value; window.location.href = url_add; } //--> </script> {/literal}



3) And finally add this new form to the same <x-cart_directory>/skin1/customer/home.tpl template file.

Code:
<FORM NAME="form"> <select name="list" onChange="nav()"> <OPTION value="" >Select category...</OPTION> {foreach from=$sub item=s} <option value="home.php?cat={$s.categoryid}">{$s.category}</option> {/foreach} </select> </FORM>



If you are looking to take some of the catagories out of the A-Z list then find {foreach from=$sub item=s}
<option value="home.php?cat={$s.categoryid}">{$s.category} </option>
in home.tpl and replace with:

{foreach from=$sub item=s}
{if ($s.category ne "Catagory1")
and ($s.category ne "Catagory2")
and ($s.category ne "Catagory3")
and ($s.category ne "Catagory4")}
<option value="home.php?cat={$s.categoryid}">{$s.category} </option>
{/if}


Catagory 1, 2, 3, 4 represents the catagory names which it will take out of the list. You can have as many as you like in the list. just make sure the last catagory ends with )} like above.

This works on 4.0.14 but im sure it will be fine for other versions. I would like if anyone maybe able to add ideas or further develop this.

thanks
__________________
xcart version 4.1.6
UK - Brighton

QVS ELECTRICAL SUPPLIES - http://www.qvsdirect.com

We supply a huge range of cables, electrical accessories, heating, ventilation, fire and security products, consumer units & circuit distribution, indoor and outdoor lighting, showers and water heating, tools and fixings, timer switches, sockets, switches, air conditioning, trunking, and much much more.
Reply With Quote
  #2  
Old 04-09-2007, 10:40 AM
  girlsbits's Avatar 
girlsbits girlsbits is offline
 

Advanced Member
  
Join Date: May 2006
Posts: 77
 

Default Re: A-Z Dropdown Listings - Helpful Navigation

Great mod - I've been looking for something like this.

Nice one, thanks.
__________________
X-Cart Gold | v 4.0.18 | Unix | php 4.3 | phpMyAdmin 2.8.0.3 |
Reply With Quote
  #3  
Old 04-14-2007, 02:27 AM
 
QVS QVS is offline
 

Senior Member
  
Join Date: Nov 2004
Posts: 136
 

Default Re: A-Z Dropdown Listings - Helpful Navigation

glad its helped

tested on 4.1.6 - works fine.
__________________
xcart version 4.1.6
UK - Brighton

QVS ELECTRICAL SUPPLIES - http://www.qvsdirect.com

We supply a huge range of cables, electrical accessories, heating, ventilation, fire and security products, consumer units & circuit distribution, indoor and outdoor lighting, showers and water heating, tools and fixings, timer switches, sockets, switches, air conditioning, trunking, and much much more.
Reply With Quote
  #4  
Old 09-06-2007, 09:57 PM
 
mixshows mixshows is offline
 

Newbie
  
Join Date: Jul 2007
Posts: 6
 

Default Re: A-Z Dropdown Listings - Helpful Navigation

THIS IS AMAZING! thanks!

its exactly what I was looking for, now I have 2 questions

1) how do I make the "manufacturers" list instead of "categories"

2) right now, after you select the category it goes back to "select category.." how do I make the "select category.." automatically change to display the current category or manufacturer after the selection is made?

thank you very much, and I appreciate all youve done
__________________
Version 4.1.8
Reply With Quote
  #5  
Old 10-25-2007, 12:34 PM
  shopccp's Avatar 
shopccp shopccp is offline
 

Advanced Member
  
Join Date: Oct 2006
Posts: 35
 

Default Re: A-Z Dropdown Listings - Helpful Navigation

very nice mod. but there's a minor error with it. when the user selects a category from the drop down list, the category shows up as well as database errors. what is the fix to hide those database errors?

Code:
INVALID SQL: 1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xcart_products.forsale='Y' and xcart_products.avail>0 and xcart_products.sales_s' at line 1 SQL QUERY FAILURE:SELECT xcart_products.productid, IF(xcart_products_lng.productid != '', xcart_products_lng.product, xcart_products.product) as product, xcart_products.productcode, xcart_products.avail, xcart_pricing.price, xcart_quick_prices.variantid, IFNULL(xcart_variants.avail, xcart_products.avail) as avail, IFNULL(xcart_variants.weight, xcart_products.weight) as weight, IFNULL(xcart_variants.productcode, xcart_products.productcode) as productcode, IF(xcart_classes.classid IS NULL,'','Y') as is_product_options, IF(xcart_variants.variantid IS NULL,'','Y') as is_variant, IF(xcart_images_T.id IS NULL, '', 'Y') as is_thumbnail, xcart_images_T.image_path, xcart_product_taxes.taxid FROM xcart_pricing, xcart_products LEFT JOIN xcart_products_lng ON xcart_products.productid = xcart_products_lng.productid AND code = 'US' LEFT JOIN xcart_quick_prices ON xcart_quick_prices.productid = xcart_products.productid AND xcart_quick_prices.membershipid = '0' LEFT JOIN xcart_product_memberships ON xcart_product_memberships.productid = xcart_products.productid LEFT JOIN xcart_classes ON xcart_classes.productid = xcart_products.productid LEFT JOIN xcart_variants ON xcart_variants.productid = xcart_products.productid AND xcart_quick_prices.variantid = xcart_variants.variantid LEFT JOIN xcart_images_T ON xcart_images_T.id = xcart_products.productid LEFT JOIN xcart_product_taxes ON xcart_product_taxes.productid = xcart_products.productid INNER JOIN xcart_products_categories ON xcart_products_categories.productid = xcart_products.productid INNER JOIN xcart_categories ON xcart_categories.categoryid = xcart_products_categories.categoryid AND xcart_categories.avail = 'Y' LEFT JOIN xcart_category_memberships ON xcart_category_memberships.categoryid = xcart_categories.categoryid WHERE (xcart_category_memberships.membershipid = '' OR xcart_category_memberships.membershipid IS NULL) AND xcart_products.forsale='Y' AND (xcart_product_memberships.membershipid = '' OR xcart_product_memberships.membershipid IS NULL) AND xcart_quick_prices.priceid = xcart_pricing.priceid AND xcart_products.productid = xcart_products_categories.productid AND xcart_products_categories.categoryid = xcart_categories.categoryid AND xcart_products.productid = xcart_pricing.productid AND xcart_pricing.quantity = '1' AND xcart_pricing.membershipid = '0' AND (xcart_pricing.variantid = '0' OR xcart_variants.variantid = xcart_pricing.variantid) AND (IFNULL(xcart_variants.avail, xcart_products.avail) > '0' OR xcart_products.product_type NOT IN ('','N'))xcart_products.forsale='Y' and xcart_products.avail>0 and xcart_products.sales_stats > 0 AND xcart_categories.avail='Y' and price>0 group by xcart_products.productid order by sales_stats DESC, views_stats DESC limit GROUP BY xcart_products.productid ORDER BY xcart_products_categories.orderby INVALID SQL: 1072 : Key column 'pam' doesn't exist in table SQL QUERY FAILURE:SELECT categoryid FROM xcart_categories USE INDEX (pam) WHERE categoryid_path LIKE '2/47/88/%' AND avail='Y'
__________________
X-Cart Gold v4.4.4
Apache v2.2.20
PHP v5.3.8
MySQL v5.1.56-log
Linux kernel v2.6.18-238.19.1.el5xen
Reply With Quote
  #6  
Old 11-10-2007, 09:43 AM
 
digiemp digiemp is offline
 

Senior Member
  
Join Date: Aug 2007
Posts: 192
 

Default Re: A-Z Dropdown Listings - Helpful Navigation

Thanks for the nice mod.
I have a question though.
The original method only displays the main categories for me, which is kind of redundant since they are already displayed in the category box. Is there a way to list all of my subcategories as well or perhaps links to static pages?

Thanks
__________________
version 4.4.2
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



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


All times are GMT -8. The time now is 07:11 PM.

   

 
X-Cart forums © 2001-2020