Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Search Select Box Question

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
machnhed1
Smarty Regular


Joined: 21 Apr 2003
Posts: 39
Location: Illinois

PostPosted: Tue Jul 22, 2003 3:21 am    Post subject: Search Select Box Question Reply with quote

Hi Everyone,

I have a search form on my shopping cart that allows customers to search the main categories (including all subcategories) and also all the first level sub categories (and all their relative subcategories). For example the select menu on the site shows:
Code:
All
Books
  Books/Internet
  Books/Software
CD - DVD - Video
  CD - DVD - Video/Subcat1
  CD - DVD - Video/Subcat2
etc...


The PHP code running in the background looks like this:
Code:
#
# Mod: Get all main categories and level 1 subcatgories and store them in an array
#
$categories_data1 = func_query("select * from $sql_tbl[categories] where category NOT LIKE '%/%' and avail='Y' group by $sql_tbl[categories].categoryid order by order_by");

foreach ($categories_data1 as $key=>$value) {
   $categories_data2[$key][] = func_query("select * from $sql_tbl[categories] where category LIKE '".$value[category]."/%' and category NOT LIKE '".$value[category]."/%/%' and avail='Y' group by $sql_tbl[categories].categoryid order by order_by");
   $categories_data2[$key][category] = strrchr($categories_data2[$key][category], "/");
   }


Then I displayed it in the search.tpl with the following:
Code:
<select name="in_category">
          <option value="">All</option>         
{section name=cat_num loop=$categories_level_1}
          <option value="{ $categories_level_1[cat_num].categoryid}" {if $smarty.get.in_category eq $categories_level_1[cat_num].categoryid or $cat eq $categories_level_1[cat_num].categoryid}selected{/if}>
          {$categories_level_1[cat_num].category|escape}
          </option>

{section name=cat_num1 loop=$categories_level_2}
          {if $categories_level_2[cat_num][0][cat_num1].categoryid ne ""}<option value="{ $categories_level_2[cat_num][0][cat_num1].categoryid}" {if $smarty.get.in_category eq $categories_level_2[cat_num][0][cat_num1].categoryid or $cat eq $categories_level_2[cat_num][0][cat_num1].categoryid}selected{/if}>
          &&{$categories_level_2[cat_num][0][cat_num1].category|escape}
          </option>{/if}     
{/section}
                 
{/section}
        </select>


My question is this: Can anyone figure out how I can modify the subcategories so that only the subcategory shows up in the drop down box? So it would be -
Code:

All
Books
  Internet
  Software
CD - DVD - Video
  Subcat1
  Subcat2
etc...


I would really appreciate any help I am brain farting at the moment. Smile

Thanks everyone.
_________________
"Every operating system out there is about equal in the number of vulnerabilities reported. We all suck."

- Microsoft Senior Vice President Brian Valentine
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP