X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   HTML select option box for root and sub caregories problem (https://forum.x-cart.com/showthread.php?t=55656)

Jeremy Smith 09-22-2010 08:32 AM

HTML select option box for root and sub caregories problem
 
I am having real problems understanding how to do this.

It make sense in my head but it just is not working, can someone help?

Right here's the code I have used:

Code:

<div id="printerSearchMiddle">
{* $Id: categories.tpl,v 1.26.2.4 2008/07/22 07:58:28 ferz Exp $ *}
{capture name=menu}
{if $active_modules.Fancy_Categories ne ""}
{assign var="fc_cellpadding" value="0"}
{else}
{if $config.General.root_categories eq "Y"}


<form name="catForm">Manufacturer:

<select onChange="document.catForm.submit()">
{foreach from=$categories item=c}
<option value="{$c.categoryid}" {if $current_category eq {$c.categoryid}selected{/if}>
{$c.category}
</option>
{/foreach}
</select>

Model:

<select onChange="document.catForm.submit()">

{foreach from=$subcategories item=c key=catid}
<option value="home.php?cat={$catid}">{$c.category}</option>
{/foreach}

</select>

</form>

{else}

{/if}
{/if}
{/capture}
{ include file="menuDropDown.tpl" menu_content=$smarty.capture.menu }
</div>


What I basically want it to do, is the user selects say:

category1 (a root category)

All the sub categories for this root category display (of course the root category still being visible)

But then what I want it to do, when the sub category is selected and the customer is able to view all products within that sub category.

The root category is still selected and can view all sub categories within that root if you like.

How can I amend my above code to reflect this need?

Just looks rather confusing to the user at the moment and its really starting to annoy me, should work, probably just something I have missed out or forgotten about.

Any help is wonderfully appreciated,
Jeremy.

Jeremy Smith 09-23-2010 03:51 AM

Re: HTML select option box for root and sub caregories problem
 
Ive finally got it:

Quote:

{* $Id: categories.tpl,v 1.26.2.4 2008/07/22 07:58:28 ferz Exp $ *}
{capture name=menu}
{if $active_modules.Fancy_Categories ne ""}
{assign var="fc_cellpadding" value="0"}
{else}
{if $config.General.root_categories eq "Y"}


{* <form name="catForm">Manufacturer:
<select name="rootCat" onChange="window.location=document.catForm.rootCat .options[document.catForm.rootCat.selectedIndex].value">



<option value="">Please select: </option>

{foreach from=$categories item=c}

<option value="home.php?cat={$c.categoryid}">{$c.category} </option>

{/foreach}

</select>

Model:

<select id="subCat" name="subCat">

<option value="#"></option>

{foreach from=$subcategories item=c key=catid}
<option value="home.php?cat={$catid}">{$c.category}</option>
{/foreach}

</select>

<input type="button" name="go" value="Select" onClick="window.location=document.catForm.subCat.o ptions[document.catForm.subCat.selectedIndex].value">

</form> *}



<form method="get" action="home.php">
Manufacturer:
<select name="cat" onchange="this.form.submit()">
<option value="0"{if $cat eq "0"} selected{/if}>Select Manufacturer...</option>
{foreach from=$categories item=c}
<option value="{$c.categoryid}"{if $cat eq $c.categoryid} selected{/if}>{$c.category}</option>
{/foreach}
</select>

Please select:
<select name="subcat" onchange="this.form.submit()">
<option value="0"{if $cat eq "0"} selected{/if}>Printers...</option>
{foreach from=$subcategories item=c key=catid}
<option value="{$catid}"{if $cat eq $catid} selected{/if}>{$c.category}</option>
{/foreach}
</select>
</form>

{else}

{/if}
{/if}
{/capture}
{ include file="menuDropDown.tpl" menu_content=$smarty.capture.menu }
</div>
<div id="printerSearchBottom"></div>

As far as I am concerned this is now closed as an issue.

Thanks,
Jeremy


All times are GMT -8. The time now is 07:08 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.