4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started 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
while ($image_row = $site_db->fetch_array($result)) {
Replace with:
$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:
$content = $thumbnails;
unset($thumbnails);
Add after:
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:
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
Add after:
"catlist" => $catlist, // Result category list
Step 4: In lang/yourlang/main.php, add before ?>:
$lang['searchresult_catlist_sep'] = '<li>'; // Result category list
Step 5: Add in search.html:
{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.
-
I can only say : it works perfectly ... :D
thanks for this tiny but useful modification !
mawenzi
-
Great mod :D
-
... 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 :
array_push( $catlist_ary, get_category_path( $image_row['cat_id'], 1 )." » ".htmlspecialchars(stripslashes($org_search_keywords))); // Result category
-
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 « manually -- it'll defer to the regular cat separator.
Thanks!
-
cooler MOD
Thank you! It works fine!
Steffen
-
Eben eingebaut und gefällt :)
Thanks for this...
-
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
-
I'm unable to reproduce the error. Can you please let me know exactly what you're doing when this error appears?
-
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
-
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:
//-----------------------------------------------------
//--- 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
-
Hi Jasmine,
Great mod!
it works perfectly ...
Useful modification !
Thank You!
Best Regards
m.a
-
i am gonna try this mod tonite thanks jasmine for this wonderful modification
-
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
-
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
-
:evil:
It want work with Version 1.7.4!
Did anybody make some experience with this Version?
-
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?
-
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:
//-----------------------------------------------------
//--- 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
-
change:
"catlist" => $catlist
for:
"catlist" => (isset($catlist)) ? $catlist : ""
-
Any way to say how many images were found in each of the categories listed with a number?
Great mod thanks!
-
in step 1 use this code:
$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:
ksort($catlist_ary); // Result category list
$catlist = "";
foreach($catlist_ary as $key => $val)
{
$catlist .= $lang['searchresult_catlist_sep'] . $key . " (".$val.")";
}
-
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 //-----------------------------------------------------
//--- 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 ?