Subcategories In Advanced Search
Posted: 08 August 2004 03:56 AM   [ Ignore ]  
Grad Student
Rank
Total Posts:  85
Joined  04-23-2002

Is there a way to exclude the subcategories from the advanced search? Only the main categories should be listed in the search; but the subcategories should be included in the search itself!

The problem: I have many subcategories with the same name which is totally confusing in the search form.

My categories:

Car model A
—- Electric
—- Body
—- Engine
—- Transmission
—- Security
etc.

Car model B
—- Electric
—- Body
—- Engine
—- Transmission
—- Security
etc.

Car model C
—- Electric
—- Body
—- Engine
—- Transmission
—- Security
etc.

While the categories are displayed linear in the search form, you have no idea to which main category the subcategories belong. Something like “parent only” should be nice.

Profile
 
 
Posted: 08 August 2004 09:16 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
RankRank
Total Posts:  119
Joined  07-15-2002

I’m interested in the answers you receive, but I also wanted to say that your site is an ideal site for a “faceted” categorization system, which is what I am creating with my EE site. There are two facets in the above example: you could call them “model” and “subsystem”, like this:

Model (Model A, Model B, Model C, etc…)
Subsystem (Electric, Body, Engine, Transmission, Security, etc…)

There could also be other facets, such as the year of the model. Each facet can also be hierarchical, but if its subcategories are repeated, as in your example, then a new facet is called for.

My site’s users will be able to select one or more items from each facet in order to narrow the search rapidly and intuitively.

I’m going to do a lot of code customization for this, and maybe a plugin or module will result. (No promises.) But there are some fairly simple ways to implement this with minimal hacking. In your case, I would use the EE categories for car models only (you can still use the hierarchical aspect for Make>Model), and I would create a custom drop-down weblog field for “subsytem”. Then all you need is to modify your Advanced search template to include a Subsystem drop-down menu, and modify the search query code to include the user’s Subsystem selection.

I’ll be happy to tell you all the details… as soon as I figure them out. grin

FYI: here’s more info about faceted browsing/searching systems.

Profile
 
 
Posted: 08 August 2004 09:24 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Rank
Total Posts:  85
Joined  04-23-2002

Thanks Scott! I’m looking forward to reading the details ...

What do you mean by I would create a custom drop-down weblog field for “subsytem”? A drop-down weblog field? What do you refer to?

Profile
 
 
Posted: 08 August 2004 09:45 AM   [ Ignore ]   [ # 3 ]  
Lab Assistant
RankRank
Total Posts:  119
Joined  07-15-2002

Yes - a custom weblog field set to “Drop-down List” (instead of Text Input or Textarea), with the actual subsystems listed in the Select Options field.

The above refers to the settings in Control Panel Home : Admin : Field Groups : Custom Fields

Profile
 
 
Posted: 08 August 2004 10:27 AM   [ Ignore ]   [ # 4 ]  
Grad Student
Rank
Total Posts:  85
Joined  04-23-2002

Okay - I understand.

Later I try to modify the search template as you suggested. But I’m still not sure if the following works with your solution - and how:

With categories and subcategories I can navigate quickly to entries that belong to car model A -> engine. But how can I get quick access to these entries when I don’t have subcategories? I need a navigation bar which let’s the user navigate to model A -> engine. In the case he can only choose the model, he gets too many entries listed.

Profile
 
 
Posted: 09 August 2004 01:11 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
RankRank
Total Posts:  119
Joined  07-15-2002

derschlendrian—I’m sorry I don’t have time to write the full code, but I’ll give you the gist of one way you could implement a two-faceted browsing setup…

First, I’m assuming you intend to have dozens of car models in your knowledgebase, if you were only going to have a few models, then a faceted browse/search would be overkill. But if you had 50 models and 10 subsystems per model, users would have to wade through 500 menu items to find the right one. With a faceted browse, the user selects the model and the subsystem in two clicks instead of one, but it’s faster and easier on the whole.

In your templates, you’d have two navigation menus: one with a list of models and the other with a list of subsystems. An intuitive layout for this would be to have the list of models in the left-hand column and the subsystems as tabs across the top of the content area.

You’d need to use URL segments to tell EE what the user has selected. Something like this:

yoursite.com/index.php/{template_group}/{template}/{model}/{subsystem}

Let’s say your template group is “articles” and your template is “browse”, like this:

yoursite.com/index.php/articles/browse/

The above URL would list ALL articles, regarless of model or subsystem. To narrow it down, the user clicks on “Model A” in the left-hand column menu, which links to…

yoursite.com/index.php/articles/browse/model_a/all/

...which lists articles for ALL subsystems of Model A.

Next, the user clicks on the “Engine” tab, which links to…

yoursite.com/index.php/articles/browse/model_a/engine/

...which lists only the articles related to the Model A engine.

The user could have clicked on the Engine tab first (prior to selecting the model), which would link to…

yoursite.com/index.php/articles/browse/all/engine/

...and would list ALL engine articles, regardless of model.

Then the user would click on “Model A” in the models menu, which would lead to the same destination as above:

yoursite.com/index.php/articles/browse/model_a/engine/

The “browse” template would need some php code to correctly set the URLs for the links in the model menu and subsystem tabs, based on the values (or non-existence) of {segment_3} and {segment_4}. The template would also need to use a {exp:query…} tag to select which articles to list. The query tag for the above URL would select entries where the category is “Model A” and the subsystem field is “engine”.

Note: all of the above describes a system for browsing rather than a typical search, but the strategy for searching would be similar. You’d add a subsystem drop-down menu to the Advanced Search template, and the search module might need a little hacking to include the subsystem selection in the search criteria.

I hope that’s not too confusing.

Profile
 
 
Posted: 09 August 2004 08:19 AM   [ Ignore ]   [ # 6 ]  
Grad Student
Rank
Total Posts:  85
Joined  04-23-2002

It’s not that confusing, Scott. I enjoy your ideas. I was looking for a solution like yours. Although I’ve never used the query modul tags, I can imagine what the query should be like.

At the moment there’s one problem I can’t solve by myself:

The template “engine” lists all entrys with exp_weblog_data.field_id_7 = ‘engine’, but how can I tell the system to limit the result of the query to the category (model) I’ve choosen.

E. g.: I start on page yoursite.com/index.php/articles/browse/model_a/ and follow the link to model a (category 8). Which variable transfers this information? I suppose I need to add in the query ... WHERE exp_weblog_titles.weblog_id = ‘3’ and exp_weblog_titles.status = ‘open’ and exp_weblog_data.field_id_7 = ‘engine’ and exp_categories.cat_id = ‘?’ But at this point I don’t know which variable I need to use instead of the question mark!

Profile
 
 
Posted: 09 August 2004 08:51 AM   [ Ignore ]   [ # 7 ]  
Grad Student
Rank
Total Posts:  85
Joined  04-23-2002

My conclusion after 5 hours: It was a mistake thinking I understand the syntax of database queries. NOW I’m really confused!

Profile
 
 
Posted: 09 August 2004 11:01 AM   [ Ignore ]   [ # 8 ]  
Grad Student
Rank
Total Posts:  85
Joined  04-23-2002

Wonderful, I solved the problem with combining models und subsystems without a database query. Later I try to explain how. I still need to find a way to include the custom weblog field (subsystem) in the search.

Profile
 
 
Posted: 11 August 2004 10:36 AM   [ Ignore ]   [ # 9 ]  
Grad Student
Rank
Total Posts:  85
Joined  04-23-2002

The “browse” template would need some php code to correctly set the URLs for the links in the model menu and subsystem tabs, based on the values (or non-existence) of {segment_3} and {segment_4}. The template would also need to use a {exp:query…} tag to select which articles to list. The query tag for the above URL would select entries where the category is “Model A” and the subsystem field is “engine”.

So, this is the way - without a query:

For each subsystem (engine, body etc.) I’ve made a template. Inside the template I limit the entries to the choosen subsystem by

{exp:weblog:entries weblog=“news” limit=“15”}
{if subsystem == “engine”}

...

{/if}
{exp:weblog:entries}

Maybe there’s a smarter solution but it works.

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64907 Total Logged-in Users: 38
Total Topics: 81852 Total Anonymous Users: 35
Total Replies: 440056 Total Guests: 241
Total Posts: 521908    
Members ( View Memberlist )