Author Topic: [MOD] Search Result Category Listing  (Read 43005 times)

0 Members and 1 Guest are viewing this topic.

Offline Jasmine

  • Newbie
  • *
  • Posts: 21
    • View Profile
[MOD] Search Result Category Listing
« on: June 06, 2006, 09:23:11 PM »
This is a quick and easy mod which displays the list of categories in which the current page's search results are found.  An example is here.

Step 1: In search.php, find
Code: [Select]
  while ($image_row = $site_db->fetch_array($result)) {
Replace with:
Code: [Select]
   $catlist_ary = array(); // Result category list

  while ($image_row = $site_db->fetch_array( $result )) {

    array_push( $catlist_ary, get_category_path( $image_row['cat_id'], 1 ).$config['category_separator'].htmlspecialchars(stripslashes($org_search_keywords))); // Result category list  

Step 2: Find:
Code: [Select]
  $content = $thumbnails;
  unset($thumbnails);

Add after:
Code: [Select]
  sort($catlist_ary); // Result category list
  $catlist = $lang['searchresult_catlist_sep'] . join($lang['searchresult_catlist_sep'], array_unique($catlist_ary)); // Result category list

Step 3: Find:
Code: [Select]
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(

Add after:
Code: [Select]
  "catlist" => $catlist, // Result category list
Step 4: In lang/yourlang/main.php, add before   ?>:
Code: [Select]
$lang['searchresult_catlist_sep'] = '<li>'; // Result category list

Step 5: Add in search.html:
Code: [Select]
{if catlist}
   <!-- Start Result category list-->
  <h4>category results:</h4>
  <div style="height: 100px; border: 1px dashed #47697e; overflow: auto;">
         <ul>{catlist}</ul>
  </div>
  <!-- End Result category list-->
{endif catlist}

Update: 2006/06/06 20:29: Included mawenzi's suggestion to include search keywords to category string.
« Last Edit: April 26, 2009, 11:57:50 PM by V@no »

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] Search Result Category Listing
« Reply #1 on: June 06, 2006, 09:50:31 PM »
I can only say : it works perfectly ...  :D
thanks for this tiny but useful modification !

mawenzi
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline aletapety

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: [MOD] Search Result Category Listing
« Reply #2 on: June 07, 2006, 12:30:33 AM »
Great mod  :D

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] Search Result Category Listing
« Reply #3 on: June 07, 2006, 01:51:33 AM »
... a little addon ...  :wink:

... if you want to show the search keywords at the end of the category path ( like : > keyword ) ...
... example here ...
... then use this codeline in step 1 :
Code: [Select]
array_push( $catlist_ary, get_category_path( $image_row['cat_id'], 1 )."&nbsp;&raquo;&nbsp;".htmlspecialchars(stripslashes($org_search_keywords))); // Result category
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline Jasmine

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: [MOD] Search Result Category Listing
« Reply #4 on: June 07, 2006, 04:01:18 AM »
Excellent change!  For consistency, I changed that same line to:
[qcode]    array_push( $catlist_ary, get_category_path( $image_row['cat_id'], 1 ).$config['category_separator'].htmlspecialchars(stripslashes($org_search_keywords))); // Result category[/qcode]
I've updated the original post so that no one has to change the &laquo; manually -- it'll defer to the regular cat separator.

Thanks!
« Last Edit: June 07, 2006, 07:42:39 AM by Jasmine »

Offline IWS_steffen

  • Full Member
  • ***
  • Posts: 128
    • View Profile
    • Kreuzfahrtschiffe gestern und heute
Re: [MOD] Search Result Category Listing
« Reply #5 on: June 12, 2006, 11:21:48 PM »
cooler MOD

Thank you! It works fine! 

Steffen

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Re: [MOD] Search Result Category Listing
« Reply #6 on: September 30, 2006, 11:53:50 PM »
Eben eingebaut und gefällt :)

Thanks for this...
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline kleiner_Hobbit

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
    • Berlin in Bildern
Re: [MOD] Search Result Category Listing
« Reply #7 on: October 01, 2006, 01:59:19 AM »
Quote
es wäre toll, wenn alle kategorien für alle gesuchten bilder auf der hauptseite anzeigt werden.
Ganz dreist hänge ich mich mal an diese Idee ran und hätte noch einen Vorschlag/Wunsch  :wink:

Wenn man die Kategorie-Links über den Suchergebnissen anklickt, dann wird man auf die jeweilige Kategorie weitergeleitet. Ich würde es noch viel besser finden, wenn man dann nicht alle Bilder der Kategorie angezeigt bekommt, sondern nur die entsprechenden Suchergebnisse der Kategorie.

Ich vermute aber mal, dass diese Modifikation sehr aufwendig ist.

Viele Grüße

Claudia

Offline Jasmine

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: [MOD] Search Result Category Listing
« Reply #8 on: October 29, 2006, 03:47:34 AM »

I'm unable to reproduce the error.  Can you please let me know exactly what you're doing when this error appears?

Offline Jasmine

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: [MOD] Search Result Category Listing
« Reply #9 on: October 30, 2006, 12:50:03 AM »
Because I can't reproduce the error and have no experience with xampp, all I can suggest is that you try adding

$catlist = '';

before the following line:

$catlist_ary = array(); // Result category list


Offline m.a

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
Re: [MOD] Search Result Category Listing
« Reply #10 on: February 01, 2007, 03:42:21 PM »
hi jasmine,
when a new version (1.7.4) with this mod, comes this error
im use a offline xampp software to preview on my website

Hi Ivan,

Try in Setup 3 with this:
Code: [Select]
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
if(!isset($catlist)){
$catlist = '';
}
$site_template->register_vars(array(
/*#########[MOD] Search Result Category Listing ##################*/
"catlist" => $catlist, // Result category list
/*#########Ende Search Result Category Listing ##################*/

Notice: Undefined variable: catlist in E:\Localserver\httpdocs\bildergallery1.7.4\search.php on line 368
That is one problem with php without isset check!

Best Regards
m.a

Offline m.a

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
Re: [MOD] Search Result Category Listing
« Reply #11 on: February 01, 2007, 03:43:10 PM »
Hi Jasmine,

Great mod!
it works perfectly ... 
Useful modification !
Thank You!

Best Regards
m.a

Offline __G__

  • Sr. Member
  • ****
  • Posts: 286
    • View Profile
Re: [MOD] Search Result Category Listing
« Reply #12 on: February 01, 2007, 05:09:20 PM »
i am gonna try this mod tonite thanks jasmine for this wonderful modification

Offline __G__

  • Sr. Member
  • ****
  • Posts: 286
    • View Profile
Re: [MOD] Search Result Category Listing
« Reply #13 on: February 02, 2007, 03:31:12 AM »
wow installed it its working real good one question when the search thing comes up is it possible to make that image name a hyper link which will take us to that image :D

Offline CeJay

  • Sr. Member
  • ****
  • Posts: 425
    • View Profile
Re: [MOD] Search Result Category Listing
« Reply #14 on: February 02, 2007, 07:18:01 AM »
Can not believe I didn't notice this mod sooner, great addition!

@m.a
Thanks for your code, kept thinking I was inserting something wrong