Author Topic: [Mod] More Like This link or button - search w/ all keywords  (Read 16183 times)

0 Members and 1 Guest are viewing this topic.

Offline jengwen

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
    • http://www.jenrichardsphotography.com
[Mod] More Like This link or button - search w/ all keywords
« on: March 13, 2003, 03:20:22 AM »
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 :oops: ).  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):
Code: [Select]
$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:
Code: [Select]
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)) ? "&amp;mode=".$mode : ""))."\"><img src=\"".get_gallery_image("postcard.gif")."\" border=\"0\" alt=\"".$lang['alt_postcard']."\"/></a>";
  }

and add after:
Code: [Select]
 $morelike_link = "<a href=\"".$site_sess->url(ROOT_PATH."search.php?search_keywords=".$image_row['image_keywords'].((!empty($mode)) ? "&amp;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)) ? "&amp;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:
Code: [Select]
   "postcard_button" => $postcard_button,
and add after:
Code: [Select]

    "morelike_button" => $morelike_button,
    "morelike_link" => $morelike_link,


search.php
find:
Code: [Select]
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:
   
Code: [Select]
$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.com

This is my first mod, so forgive any code that could be done better.  Hopefully some one else will find this useful.

Offline Lunique

  • Full Member
  • ***
  • Posts: 109
  • V 1.7.7
    • View Profile
Re: [Mod] More Like This link or button - search w/ all keywords
« Reply #1 on: April 15, 2006, 02:24:57 AM »
Nice mod, works fine ;)

Offline Lunique

  • Full Member
  • ***
  • Posts: 109
  • V 1.7.7
    • View Profile
Re: [Mod] More Like This link or button - search w/ all keywords
« Reply #2 on: June 17, 2006, 09:33:33 PM »
Is it possible to make the same button for pictures with the same description or filename ?

Offline AntiNSA2

  • Hero Member
  • *****
  • Posts: 774
  • As long as I can finish my site before I die.
    • View Profile
    • http://www.thelifephotography.com
Re: [Mod] More Like This link or button - search w/ all keywords
« Reply #3 on: March 10, 2009, 10:43:53 AM »
This mod only returns images with the exact keywords... is there away to say like with most of these keywords, and return a search in relevance to keyword search?
As long as I can finish my site before I die.