This mod will allow you to find all images containing the same keywords as the current image or thumbnail. The thumbnails returned will contain all of the keywords of the selected image, but may have additional keywords of their own as well. I wanted this because my images aren't always sorted in an order that groups like images together. For example, I have a folder with zoo pictures, but they don't show up in order of animal, so this button will bring up all images of that animal (if your keywords are set up well - mine still need some work
). Here is what to change:
lang/english(or other language)/
main.php - add the following lines (I added mine under the misc and alt language headings):
$lang['morelike'] = "More Like This";
$lang['alt_morelike'] = "Find more images with these keywords";
functions.php (this is where I added mine, but probably could go other places)
find:
if (!check_permission("auth_sendpostcard", $image_row['cat_id'])) {
$postcard_button = "<img src=\"".get_gallery_image("postcard_off.gif")."\" border=\"0\" alt=\"".$lang['alt_postcard_off']."\"/>";
}
else {
$postcard_button = "<a href=\"".$site_sess->url(ROOT_PATH."postcards.php?".URL_IMAGE_ID."=".$image_row['image_id'].((!empty($mode)) ? "&mode=".$mode : ""))."\"><img src=\"".get_gallery_image("postcard.gif")."\" border=\"0\" alt=\"".$lang['alt_postcard']."\"/></a>";
}
and add after:
$morelike_link = "<a href=\"".$site_sess->url(ROOT_PATH."search.php?search_keywords=".$image_row['image_keywords'].((!empty($mode)) ? "&mode=".$mode : ""))."\">More Like This</a>";
$morelike_button = "<a href=\"".$site_sess->url(ROOT_PATH."search.php?search_keywords=".$image_row['image_keywords'].((!empty($mode)) ? "&mode=".$mode : ""))."\"><img src=\"".get_gallery_image("morelike.gif")."\" border=\"0\" alt=\"".$lang['alt_morelike']."\"/></a>";
Note: I had to type 'More Like This' for the link, because I couldn't get it to work using lang_morelike. I tried several variations without success, so if someone fixes this part please post the change.
find:
"postcard_button" => $postcard_button,
and add after:
"morelike_button" => $morelike_button,
"morelike_link" => $morelike_link,
search.php find:
if (isset($HTTP_POST_VARS['search_terms'])) {
$search_terms = (trim($HTTP_POST_VARS['search_terms']) == "all") ? 1 : 0;
}
else {
$search_terms = 0;
}
change search_terms = 0 to:
$search_terms = 1;
Note: I tried to get this mod to work by passing a search_term=all, but it didn't work, so I just changed the default to be AND. I prefer this as the default for all my searches anyway.
in
detail.html add {morelike_button} beneath image by other buttons or wherever you prefer it to be.
in
thumnail_bit.html add {morelike_link} above lightbox button or wherever you want it.
You will also need a button called
morelike.gif in your templates/xxx/images folder. I tried to cut and paste mine here, but couldn't get it to work (Jan, if there is a way let me know, or I can email it to you). All I did was take one of my other buttons and modified the text on it.
If you want to see it in action, check out:
http://www.jenrichardsphotography.comThis is my first mod, so forgive any code that could be done better. Hopefully some one else will find this useful.