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)
-   -   Simple dropdown loop to show subcategories (https://forum.x-cart.com/showthread.php?t=48773)

Sunbreaks 07-23-2009 03:09 PM

Simple dropdown loop to show subcategories
 
1 Attachment(s)
Hi there,

I'd like to have some very simple dropdown menus, but I'm stuck. So far the dropdowns are being created correctly, but I can't get them to list the subcategories as the options. Here's my code:

Code:

{capture name=menu}

<form name="side_searchform" action="saunders_search.php?cat={$catid}" method="post">
<table cellpadding="4" cellspacing="1">
{foreach from=$subcategories item=c key=catid}
    {if $c.category}
        {assign var="tmp" value="1"}
    {/if}
    <tr><td>
    <select name="{$c.category}">
    {if $subcategories}
        {foreach from=$subcategories item=subcat}
            {if $tmp and $first_subcat ne "Y"}
                {assign var="first_subcat" value="Y"}
            {/if}
            <option value="{ $subcat.category|escape }">{ $subcat.category|escape }
        {/foreach}
    {/if}
    </select>
    <input type=submit value="GO">
    </td></tr>
{/foreach}
</table>
</form>
{/capture}
{ include file="saunders_menu.tpl" menu_content=$smarty.capture.menu}


And here's what it looks like:
http://forum.x-cart.com/attachment.php?attachmentid=1598&stc=1&d=124839039 5
As you can see, the dropdown options are exactly the same as the main categories, rather than listing the subcategories.

Can someone please tell me how to get the option values to get down into my subcategories?

Thanks very much!
Sunbreaks

Victor D 07-27-2009 12:15 PM

Re: Simple dropdown loop to show subcategories
 
Do you want to dispay subcategories of the current category or All the categories of your store?

Sunbreaks 07-28-2009 08:37 PM

Re: Simple dropdown loop to show subcategories
 
It is correctly showing the main categories as the select, but then I need it to show the subcategories of each in the option area of the drop down menu. Does that make sense?

Sunbreaks 08-01-2009 02:19 PM

Re: Simple dropdown loop to show subcategories
 
Hi there - still waiting to hear if anyone has a suggestion on this. Anyone?

Thanks,
Sunbreaks

Victor D 08-04-2009 06:34 AM

Re: Simple dropdown loop to show subcategories
 
$subcategories is actually the subcategories of the current category, try $all_categories instead

Sunbreaks 08-07-2009 05:34 PM

Re: Simple dropdown loop to show subcategories
 
Thank you so much for the reply! I tried substituting $all_categories but I don't know exactly how to insert it in my code. Right now when I try using it nothing shows up. Of course this is harder because I want all categories and their subcategories to show on all pages, including the search results page. Can you offer any more advice?

Thanks again,
Sunbreaks

ARW VISIONS 08-08-2009 04:44 AM

Re: Simple dropdown loop to show subcategories
 
I think you will need to add some code to the php in order to get this accomplished.


All times are GMT -8. The time now is 04:38 AM.

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