4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: Jasmine on June 06, 2006, 09:23:11 PM

Title: [MOD] Search Result Category Listing
Post by: Jasmine 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 (http://www.gallery.jazzhaven.com/search.htm?search_keywords=Apollo).

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.
Title: Re: [MOD] Search Result Category Listing
Post by: mawenzi on June 06, 2006, 09:50:31 PM
I can only say : it works perfectly ...  :D
thanks for this tiny but useful modification !

mawenzi
Title: Re: [MOD] Search Result Category Listing
Post by: aletapety on June 07, 2006, 12:30:33 AM
Great mod  :D
Title: Re: [MOD] Search Result Category Listing
Post by: mawenzi 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 (http://klick.kl.funpic.de/search.php?search_keywords=Kilimanjaro) ...
... 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
Title: Re: [MOD] Search Result Category Listing
Post by: Jasmine 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!
Title: Re: [MOD] Search Result Category Listing
Post by: IWS_steffen on June 12, 2006, 11:21:48 PM
cooler MOD

Thank you! It works fine! 

Steffen
Title: Re: [MOD] Search Result Category Listing
Post by: JensF on September 30, 2006, 11:53:50 PM
Eben eingebaut und gefällt :)

Thanks for this...
Title: Re: [MOD] Search Result Category Listing
Post by: kleiner_Hobbit 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
Title: Re: [MOD] Search Result Category Listing
Post by: Jasmine 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?
Title: Re: [MOD] Search Result Category Listing
Post by: Jasmine 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

Title: Re: [MOD] Search Result Category Listing
Post by: m.a 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
Title: Re: [MOD] Search Result Category Listing
Post by: m.a on February 01, 2007, 03:43:10 PM
Hi Jasmine,

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

Best Regards
m.a
Title: Re: [MOD] Search Result Category Listing
Post by: __G__ on February 01, 2007, 05:09:20 PM
i am gonna try this mod tonite thanks jasmine for this wonderful modification
Title: Re: [MOD] Search Result Category Listing
Post by: __G__ 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
Title: Re: [MOD] Search Result Category Listing
Post by: CeJay 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
Title: Re: [MOD] Search Result Category Listing
Post by: Fragezeichen on July 21, 2007, 12:54:33 AM
 :evil:
It want work with Version 1.7.4!

Did anybody make some experience with this Version?
Title: Re: [MOD] Search Result Category Listing
Post by: m.a on July 21, 2007, 01:18:52 AM
Hi CHOICEANOTHERNAME,

i use version 1.7.4!
it works perfectly ... ([MOD]  Search Result Category Listing)!

m.a



:evil:
It want work with Version 1.7.4!

Did anybody make some experience with this Version?
Title: Re: [MOD] Search Result Category Listing
Post by: kowalski on August 07, 2007, 08:12:30 AM
Hi - I installed this mod yesterday and got the same error as ivan (on a new 1.7.4 gallery I'm building)

The error was occuring whenever a search returned no images (or if you made a blank search)..
eg. do a search for "xyzhrlodgahsd;gsajhfdag" and it returns no images, but also gives that error at the top


hello, wenn i report on global on
comes a error message

Notice: Undefined variable: catlist in E:\Localserver\httpdocs\bildergallery1.7.4\search.php on line 368

365   "lang_search" => $lang['search'],
366   "lang_search_catlist" => $lang['search_catlist'], // Result category list
367   "catlist" => $catlist // Result category list
368    ));

this is a fresh install of 1.7.4
the {if catlist} is not correct on advanced search (see image)

the error comes in vers. 1.7.1 etc. with error reporting on global.php




Using the updated fix by m.a below this solved the problem :) thank you


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
Title: Re: [MOD] Search Result Category Listing
Post by: thunderstrike on August 07, 2007, 02:23:47 PM
change:

Quote
"catlist" => $catlist

for:

Quote
"catlist" => (isset($catlist)) ? $catlist : ""
Title: Re: [MOD] Search Result Category Listing
Post by: AntiNSA2 on April 26, 2009, 08:26:18 PM
Any way to say how many images were found in each of the categories listed with a number?

Great mod thanks!
Title: Re: [MOD] Search Result Category Listing
Post by: V@no on April 27, 2009, 12:16:47 AM
in step 1 use this code:
Code: [Select]
  $catlist_ary = array(); // Result category list

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

    $key = get_category_path( $image_row['cat_id'], 1 ).$config['category_separator'].format_text(stripslashes($org_search_keywords), 2);
    $catlist_ary[$key] = (isset($catlist_ary[$key])) ?  $catlist_ary[$key] + 1 : 1; // Result category list

In step 2 this:
Code: [Select]
  ksort($catlist_ary); // Result category list
  $catlist = "";
  foreach($catlist_ary as $key => $val)
  {
    $catlist .= $lang['searchresult_catlist_sep'] . $key . " (".$val.")";
  }
Title: Re: [MOD] Search Result Category Listing
Post by: AntiNSA2 on May 03, 2009, 09:16:00 AM
Thank you V@no... Works great...

2 quick questions...

1) If you have a lot of different search results within categories it only shows a limited number of results... how to increase this...

and
2) even after replacing the code in step three with
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 ##################*/

I m still receiving an undefined catlist error... Anyway to get reid of the error with 1.7.6 ?