Jump to content
Latest News: (loading..)
spooks

Display matching categories in search results

Recommended Posts

This is the forum for the Display matching categories in search results contribution

 

This contribution will display matching categories results where the name matches the search, if you have the category description mod

(http://www.oscommerce.com/community/contributions,2343), there is code to include that too.

Also included is code if you have my hide categories contribution (http://addons.oscommerce.com/info/5907).

 

Included here is an sql query to add a setting in admin to control category search.

 

If a category is selected in the search, then only that (and subcategories if option set) are searched.

The from / to date filters are also applied.

I`ve also added an option to search categories only.

 

During the writing of this I found what appears to me to be a vulnerability in the search form in OSC2.2 rc1 where it could be used by a malicious attacker to inject sql or code. I have added a trap in advanced_search_result.php for this.

 

Contribution is found at http://addons.oscommerce.com/info/5918

 

I hope you all find this useful. :thumbsup:

Edited by spooks

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

Been away for a few weeks, now back and can't wait to have a look at Sam's contribution.

 

I dont have the category description mod, had a look at adding it but code conflicts with SEO contribution I have installed so diidn't add it.

also don't have the hide categories contribution installed.

 

 

Followed the instructions a couple of times and can't get it to work, when I perform a search the following error occurs:

 

 

Products meeting the search criteria

 

There is no product that matches the search criteria.

 

HEADING_TITLE_3

 

1054 - Unknown column 'cd.categories_id' in 'field list'

 

select count(distinct cd.categories_id) as total from products p left join manufacturers m using(manufacturers_id) left join specials s on p.products_id = s.products_id, products_description pd, categories c, products_to_categories p2c where cd.categories_id = c.categories_id and cd.language_id = '1' and ((cd.categories_name like '%dx9000%') )

 

[TEP STOP]

Share this post


Link to post
Share on other sites

Hi, sorry, there`s a missing instruction, I`ll update the contrib when I get time, for now

 

in advanced_search_result.php after the

 

$select_str = "select distinct cd.categories_name, cd.categories_id";

 

add:

 

$from_str = " from " . TABLE_CATEGORIES_DESCRIPTION . " cd left join " . TABLE_CATEGORIES . " c on cd.categories_id ";

 

 

there`s also a couple of entries in the advanced_search language file missing from the instructions (Its is all there in the included files).

 

At the end before the final ?>

 

add:

 

define('TEXT_SEARCH_CATEGORIES_ONLY', 'Search Categories Only');

define('HEADING_TITLE_3', 'Categories meeting the search criteria');

 

 

Cheers

 

:blush:


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

Thanks for this great contribution, it works really well.

 

Would it be possible to add a further mod?

 

On the bottom of the product info page it would be great if it was possible to add a table and list all the categories that that product was in. If these could by hyperlinks to the category it would be amazing.

 

Thanks

Frank

Share this post


Link to post
Share on other sites

Hello. Great Contrib - been searching for very long :D

 

Unfortunately it just lists the category itself but for me it would be better to see the whole breadcrumb or category tree instead

XXX-AAA->KEYWORD

instead of just

KEYWORD

 

Can someone help me out??

Edited by Sir.K.O.

Share this post


Link to post
Share on other sites
Hello. Great Contrib - been searching for very long :D

 

Unfortunately it just lists the category itself but for me it would be better to see the whole breadcrumb or category tree instead

XXX-AAA->KEYWORD

instead of just

KEYWORD

 

Can someone help me out??

 

 

Its possible, I'll take a look.


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

Uploaded new version 1.2

 

 

Result will now display the full category tree for the matching category with matching highlighted.

Added switches at start of files to simplify install:

.

$cat_desc=false;//set to true if you have category descriptions

$cat_stat=false;//set to true if you have hide category mod

$short=false; //set to true if you have short product descriptions

 

Changed Files: category_listing.php, advanced_search.php & advanced_search_result.php

 

 

Tested on PHP 4 & 5, SQL 4 & 5, osC 2.2 ms2, rc1 & rc2a and is register_globals compatible.

 

:)


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

Uploaded new version 1.3

 

 

Added option to position category results above or below product results.

Changed Files: category_listing.php, category_search_result.php, advanced_search_result.php & additional sql query.

 

 

Tested on PHP 4 & 5, SQL 4 & 5, osC 2.2 ms2, rc1 & rc2a and is register_globals compatible.


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

Thanks for replying, too many don't.

 

I hope you find it usefull.

 

:)


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

OK

My site is able to populate the categories, but full paths are not added to the category links (ie 284_450_877) when using the search capability. The links only show in this case the last 3 digits _877.

The left column where categories are shown include the full paths of those categories/subcategories/sub_subcategories as it should be; and thus able to show the category pages when clicked on such links.

Please your help with this matter will be truly appreciated.

Justino

Share this post


Link to post
Share on other sites
OK

My site is able to populate the categories, but full paths are not added to the category links (ie 284_450_877) when using the search capability. The links only show in this case the last 3 digits _877.

The left column where categories are shown include the full paths of those categories/subcategories/sub_subcategories as it should be; and thus able to show the category pages when clicked on such links.

Please your help with this matter will be truly appreciated.

Justino

 

 

Although it does not show parent categories in link, does it not still link to the correct category?, Do you have a url?


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites
Although it does not show parent categories in link, does it not still link to the correct category?, Do you have a url?

 

 

I would add the only purpose for the extra cat info in the url is to enable the original category box to display the path, however producing it is done with a lot of extra queries, my routine does just one. Not having the full path mearly makes the original category box show blank. As most people dont use the original box this should rarely be a problem.

 

On a busy site the extra queries the old box uses would be reason enough to get rid.

 

If this is a real problem I`ll look at a mod, but would avoid adding any more queries.


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites
Yep, but only link to the top categories where only the first digits are shown in the links.

See http://www.equipaxxess.org

 

 

there appears to be an error in your index.php where its loosing the $current_category_id, since you will note the breadcrumb is set to the category, but index don`t go there

 

I`ll look at a mod when I get time anyway.

 

I would also point a problem you have, on your product listing, sometimes the product link includes the cpath, sometimes not this is not a problem for osC as if cpath is not set it gets the path to the product anyway. It is a problem for you, google will index same product with different paths, & detect duplicate content & so penalise you.

 

Remove cpath refrences to product in the listing, or add rel="nofollow", same for manufacturer.


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

you are right, because the list given when doing a search provide the path _887, rather that the right one which is say 284_450_877; therefore it defaults to the main index.php with a cpath=877 page which does not exist in my sts templates!.

When you mention "Remove cpath refrences to product in the listing, or add rel="nofollow", same for manufacturer". What files am I suppose to modify??

Share this post


Link to post
Share on other sites

product_listing.php see this thread http://forums.oscommerce.com/index.php?sho...t=#entry1290816

 

you could replace that with a better listing anyway Product Listing Enhancements, Thumbnails & Manufacturer Headings http://addons.oscommerce.com/info/6051


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

All related categories (category tree) are shown for every matching category in 1.3, that can produce a large list.

 

I have uploaded V1.4, this add new options to category_listing.php:

 

$cat_tree=true;//set to true to display the full tree of category (related categories), otherwise false.

$duplicates=false;// Related categories are only shown with matching if they have not been shown already, set this to true to and it will show category from tree though its shown already.

Changed Files: category_listing.php


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

Works like a charm! How hard would it be for me to mod the category_listing.php to display the category image above the text? I'm not sure of the queries involved and the addition in the print block of code.

 

Thanks again!

 

-Gray

Share this post


Link to post
Share on other sites

after:

 

$display = '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $listing['categories_id']) . '">';

 

add:

 

$display .= tep_image(DIR_WS_IMAGES . $listing['categories_image'], $listing['categories_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) .'<br>';

 

and add c.categories_image, to query


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×