Author Topic: [MOD] Custom Search Template  (Read 25074 times)

0 Members and 1 Guest are viewing this topic.

Offline Acidgod

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 2.421
  • It's me?
    • View Profile
    • Flash-Webdesign
[MOD] Custom Search Template
« on: December 01, 2005, 04:39:17 PM »
Just a littel and simple MOD but it works and can be useful... (o:

Open the search.php

serach for:
Quote
$main_template = 'search';

replace with:
Quote
$mode = $HTTP_GET_VARS['mode'];
 if ($mode==""){
 $main_template = 'search';
 } else {
 $main_template = 'search_'.$mode;
 }

search for:
Quote
$content = $site_template->parse_template("search_form");

replace with:
Quote
if ($mode==""){
 $content = $site_template->parse_template("search_form");
} else {
 $content = $site_template->parse_template("search_form_".$mode);
}

make a Copy of the seach_form.html and name it for Example seach_form_colorsearch.html
And also make a Copy of the search.html and name it search_colorsearch.html

Open the seach_form_colorsearch.html

search for:
Quote
<form method="post" action="{url_search}">

replace with:
Quote
<form method="post" action="{url_search}?mode=colorsearch">

Now when you are call the Search like this /search.php?mode=colorsearch the new search_colorsearch.html & search_form_colorsearch.html Template will be used... (o:

Now, for Example, you kann make a Dropdown like this one:
Quote
<select name="search_keywords" id="search_keywords">
                <option value="red">red</option>
                <option value="blue">blue</option>
                <option value="black">black</option>
</select>

Open the search_form_colorsearch.html  and replace the search inputfield:
Quote
<input type="text" name="search_keywords" size="40" value="{search_keywords}" class="input" />
with the Dropdown.

Now call the /search.php?mode=colorsearch and there is a Search where the User can only search for the three Colors in the Dropdown... (o:

Another Example:
you will make a other search, that they can only search for the Words Animal, Building, Nature and Ocean...

make a Copy of the seach_form.html and name it for Example seach_form_group.html
And also make a Copy of the search.html and name it search_group.html

Open the seach_form_group.html

search for:
Quote
<form method="post" action="{url_search}">

replace with:
Quote
<form method="post" action="{url_search}?mode=group">

Now when you are call the Search like this /search.php?mode=group the new search_group.html & search_form_group.html Template will be used... (o:

Now, for Example, you kann make a Dropdown like this one:
Quote
<select name="search_keywords" id="search_keywords">
                <option value="animal">animal</option>
                <option value="building">building</option>
                <option value="nature ">nature </option>
                <option value="ocean">ocean</option>
</select>

Open the search_form_group.html  and replace the search inputfield:
Quote
<input type="text" name="search_keywords" size="40" value="{search_keywords}" class="input" />
with the Dropdown.

Now call the /search.php?mode=group and there is a Search where the User can only search for the Keywords in the Dropdown... (o:

Offline Vincent

  • 4images Moderator
  • Addicted member
  • *****
  • Posts: 1.195
    • View Profile
    • www.foto-kocher.com
Re: [MOD] Custom Search Template
« Reply #1 on: December 01, 2005, 11:51:35 PM »
did you add it to your page?
will have a look when back from holliday!  :wink:  :D
sincerly
vincent
Beati pauperi spiritus

4images 1.7 // My Installed Mods


Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] Custom Search Template
« Reply #2 on: December 02, 2005, 12:11:42 AM »
Vincent is already again in holidays ...  8)
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 Acidgod

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 2.421
  • It's me?
    • View Profile
    • Flash-Webdesign
Re: [MOD] Custom Search Template
« Reply #3 on: December 03, 2005, 04:06:54 PM »
Sorry i have no Demo for this...
I dont need this so i have it not on my Page...
Maybe TIMT will post his Test Gallery... (o:

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: [MOD] Custom Search Template
« Reply #4 on: December 05, 2005, 10:15:18 PM »
Hi everybody

here is my "Test Gallery": www.photofront.ch
you find a demo by klicking on "Profi Suche".
I implemented check boxes and a "multi-keyword-box".

But I still have a problem.
I have a picture with keyword "blödblöd" and a picture with keyword "gelgelgel".
When I enter in the field for keywords this two keywords and click on the radio button OR, both picture should be found.
That doesn't work. It works with the original search-function.

Would be nice, when Acidgod could check the problem.  :wink:

Thanks!

Offline Acidgod

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 2.421
  • It's me?
    • View Profile
    • Flash-Webdesign
Re: [MOD] Custom Search Template
« Reply #5 on: December 06, 2005, 10:24:44 AM »
The Problem is that PHP can handel multiple select only when you put it in an Array... But the search can´t handel Arrys without modifications... )o:

the only way to get this work is to make a string of the array...

open the search.php and search for:
Code: [Select]
*************************************************************************/
and replace it with:
Code: [Select]
*************************************************************************/

if ($search_keywords_multi){
$HTTP_POST_VARS['search_keywords'] = implode(" ", $search_keywords_multi);
$HTTP_GET_VARS['search_keywords'] = implode(" ", $search_keywords_multi);
}
if ($search_keywords_check){
$HTTP_POST_VARS['search_keywords'] = implode(" ", $search_keywords_check);
$HTTP_GET_VARS['search_keywords'] = implode(" ", $search_keywords_check);
}
$HTTP_POST_VARS['search_keywords'] .= " ".$HTTP_GET_VARS['search_keywords_check'];
$HTTP_POST_VARS['search_keywords'] .= " ".$HTTP_GET_VARS['search_keywords_multi'];

Then you must use a select multiple box like this:

Code: [Select]
<select size="4" class="input" name="search_keywords_multi[]" multiple>
        <option value="Keyword1">Keyword1</option>
        <option value="Keyword2">Keyword2</option>
        <option value="Keyword3">Keyword3</option>
</select>

Then you must use  checkboxes like this:
Code: [Select]
<input type="checkbox" name="search_keywords_check[]" value="Keyword1">
<input type="checkbox" name="search_keywords_check[]" value="Keyword2">
<input type="checkbox" name="search_keywords_check[]" value="Keyword3">


@TIMT
I have done this on your Test Site and it works well... (o:

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: [MOD] Custom Search Template
« Reply #6 on: December 06, 2005, 12:21:03 PM »
Thank you! This is a great MOD!  :D

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: [MOD] Custom Search Template
« Reply #7 on: December 09, 2005, 05:39:18 PM »
How do I have to implement check boxes in the upload_form for pictures?
so the user can e.g. click on "red" and "blue" and "red" and "blue" will be stored as keywords.

Thanks!

Offline Acidgod

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 2.421
  • It's me?
    • View Profile
    • Flash-Webdesign
Re: [MOD] Custom Search Template
« Reply #8 on: December 09, 2005, 08:06:25 PM »
*g*

Don´t now at the moment...

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: [MOD] Custom Search Template
« Reply #9 on: December 09, 2005, 10:41:32 PM »
I implemented the following Code in member_uploadform.html

Code: [Select]
<table width="100%" class="row2">
                  <tr>
                   <td width="65" valign="top" class="row2">schwarz<input type="checkbox" name="image_keywords_check[]" value="schwarz"> </td>
                   <td width="65" valign="top" class="row2">grau<input type="checkbox" name="image_keywords_check[]" value="grau"> </td>
                   <td width="65" valign="top" class="row2">weiss<input type="checkbox" name="image_keywords_check[]" value="weiss"></td>
                   <td width="65" valign="top" class="row2">gelb<input type="checkbox" name="image_keywords_check[]" value="gelb"></td>
                   <td width="65" valign="top" class="row2">orange<input type="checkbox" name="image_keywords_check[]" value="orange"></td>
                   <td width="65" valign="top" class="row2">rot<input type="checkbox" name="image_keywords_check[]" value="rot"></td>
                   <td width="65" valign="top" class="row2">lila<input type="checkbox" name="image_keywords_check[]" value="lila"></td>
                   <td width="65" valign="top" class="row2">blau<input type="checkbox" name="image_keywords_check[]" value="blau"></td>
                   <td width="65" valign="top" class="row2">türkis<input type="checkbox" name="image_keywords_check[]" value="türkis"></td>
                   <td width="65" valign="top" class="row2">grün<input type="checkbox" name="image_keywords_check[]" value="grün"><br><br></td>
                 </tr>
            </table>

The following code I entered in upload.php:

Code: [Select]
if ($image_keywords_check){
$HTTP_POST_VARS['image_keywords'] = implode(" ", $image_keywords_check);
$HTTP_GET_VARS['image_keywords'] = implode(" ", $image_keywords_check);
}
 

Nice try, not more.. it doesnt work...

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: [MOD] Custom Search Template
« Reply #10 on: December 12, 2005, 10:10:51 PM »
Hi Acidgod

Within the checkboxes or within the multi selection, the OR and AND radio button works perfect. In combinatin with a keyword an a checkbox, or in combination with a keyword and a multi selection it doesn't work.

So you can enter "rot" as a keyword and select "Glück" in the multi selection and there are only image with the keyword "Glück" (www.photofront.ch / Profi Suche).

Thanks for helping me!

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: [MOD] Custom Search Template
« Reply #11 on: May 20, 2006, 05:00:11 PM »
Hi

I have a problem with the FIX 19.02.06 (regarding News Box) and the "multiple select".

When I put the code regarding the fix below

Code: [Select]
include(ROOT_PATH.'global.php');
and above the code "multiple select" I have the following problem:

The multiple select works, but when I klick on a keyword, no images are shown.

When I put the code regarding the fix below

Code: [Select]
include(ROOT_PATH.'global.php');
and below the code "multiple select" I have the following problem:

With klick on a keyword I get all pictures whith which belongs to the keyword, but the multiple select doesn't work.

here the first version:
Code: [Select]
include(ROOT_PATH.'global.php');



if (isset($HTTP_POST_VARS['show_result']) || isset($HTTP_GET_VARS['show_result'])) {
  $show_result = 1;
}
else {
  $show_result = 0;
}

//----Zeige Users Album ---27.05.05------http://www.4homepages.de/forum/index.php?topic=4107.0----------
if (isset($HTTP_POST_VARS['search_lightbox']) || isset($HTTP_GET_VARS['search_lightbox'])) {

$search_ids = str_replace(",", ", ", trim((isset($HTTP_POST_VARS['search_lightbox'])) ? trim($HTTP_POST_VARS['search_lightbox']) : urldecode(trim($HTTP_GET_VARS['search_lightbox']))));
if ($search_lightbox != "") {
   $show_result = 1;
}
}
else {
$search_lightbox = "";
}
//-------27.05.05------Ende------------


if (isset($HTTP_POST_VARS['search_keywords']) || isset($HTTP_GET_VARS['search_keywords'])) {
  $search_keywords = (isset($HTTP_POST_VARS['search_keywords'])) ? trim($HTTP_POST_VARS['search_keywords']) : urldecode(trim($HTTP_GET_VARS['search_keywords']));
  if ($search_keywords != "") {
    $show_result = 1;
  }
}
else {
  $search_keywords = "";
}
$org_search_keywords = $search_keywords;

if (isset($HTTP_POST_VARS['search_user']) || isset($HTTP_GET_VARS['search_user'])) {
  $search_user = (isset($HTTP_POST_VARS['search_user'])) ? trim($HTTP_POST_VARS['search_user']) : urldecode(trim($HTTP_GET_VARS['search_user']));
  if ($search_user != "") {
    $show_result = 1;
  }
}
else {
  $search_user = "";
}
$org_search_user = $search_user;

if (isset($HTTP_POST_VARS['search_terms'])) {
  $search_terms = (trim($HTTP_POST_VARS['search_terms']) == "all") ? 1 : 0;
}
else {
  $search_terms = 0;
}

if (isset($HTTP_POST_VARS['search_fields'])) {
  $search_fields = trim($HTTP_POST_VARS['search_fields']);
}
else {
  $search_fields = "all";
}

$search_cat = (isset($HTTP_POST_VARS['cat_id']) ) ? intval($HTTP_POST_VARS['cat_id']) : 0;

if (isset($HTTP_POST_VARS['search_new_images']) || isset($HTTP_GET_VARS['search_new_images'])) {
  $search_new_images = 1;
  $show_result = 1;
}
else {
  $search_new_images = 0;
}

if ($search_keywords_multi){
$HTTP_POST_VARS['search_keywords_multi'] = implode(" ", $search_keywords_multi);
$HTTP_GET_VARS['search_keywords_multi'] = implode(" ", $search_keywords_multi);
}
if ($search_keywords_check){
$HTTP_POST_VARS['search_keywords_check'] = implode(" ", $search_keywords_check);
$HTTP_GET_VARS['search_keywords_check'] = implode(" ", $search_keywords_check);
}
$HTTP_POST_VARS['search_keywords'] .= " ".$HTTP_GET_VARS['search_keywords_check'];
$HTTP_POST_VARS['search_keywords'] .= " ".$HTTP_GET_VARS['search_keywords_multi'];

here the second version:
Code: [Select]
include(ROOT_PATH.'global.php');

if ($search_keywords_multi){
$HTTP_POST_VARS['search_keywords_multi'] = implode(" ", $search_keywords_multi);
$HTTP_GET_VARS['search_keywords_multi'] = implode(" ", $search_keywords_multi);
}
if ($search_keywords_check){
$HTTP_POST_VARS['search_keywords_check'] = implode(" ", $search_keywords_check);
$HTTP_GET_VARS['search_keywords_check'] = implode(" ", $search_keywords_check);
}
$HTTP_POST_VARS['search_keywords'] .= " ".$HTTP_GET_VARS['search_keywords_check'];
$HTTP_POST_VARS['search_keywords'] .= " ".$HTTP_GET_VARS['search_keywords_multi'];

if (isset($HTTP_POST_VARS['show_result']) || isset($HTTP_GET_VARS['show_result'])) {
  $show_result = 1;
}
else {
  $show_result = 0;
}

//----Zeige Users Album ---27.05.05------http://www.4homepages.de/forum/index.php?topic=4107.0----------
if (isset($HTTP_POST_VARS['search_lightbox']) || isset($HTTP_GET_VARS['search_lightbox'])) {

$search_ids = str_replace(",", ", ", trim((isset($HTTP_POST_VARS['search_lightbox'])) ? trim($HTTP_POST_VARS['search_lightbox']) : urldecode(trim($HTTP_GET_VARS['search_lightbox']))));
if ($search_lightbox != "") {
   $show_result = 1;
}
}
else {
$search_lightbox = "";
}
//-------27.05.05------Ende------------


if (isset($HTTP_POST_VARS['search_keywords']) || isset($HTTP_GET_VARS['search_keywords'])) {
  $search_keywords = (isset($HTTP_POST_VARS['search_keywords'])) ? trim($HTTP_POST_VARS['search_keywords']) : urldecode(trim($HTTP_GET_VARS['search_keywords']));
  if ($search_keywords != "") {
    $show_result = 1;
  }
}
else {
  $search_keywords = "";
}
$org_search_keywords = $search_keywords;

if (isset($HTTP_POST_VARS['search_user']) || isset($HTTP_GET_VARS['search_user'])) {
  $search_user = (isset($HTTP_POST_VARS['search_user'])) ? trim($HTTP_POST_VARS['search_user']) : urldecode(trim($HTTP_GET_VARS['search_user']));
  if ($search_user != "") {
    $show_result = 1;
  }
}
else {
  $search_user = "";
}
$org_search_user = $search_user;

if (isset($HTTP_POST_VARS['search_terms'])) {
  $search_terms = (trim($HTTP_POST_VARS['search_terms']) == "all") ? 1 : 0;
}
else {
  $search_terms = 0;
}

if (isset($HTTP_POST_VARS['search_fields'])) {
  $search_fields = trim($HTTP_POST_VARS['search_fields']);
}
else {
  $search_fields = "all";
}

$search_cat = (isset($HTTP_POST_VARS['cat_id']) ) ? intval($HTTP_POST_VARS['cat_id']) : 0;

if (isset($HTTP_POST_VARS['search_new_images']) || isset($HTTP_GET_VARS['search_new_images'])) {
  $search_new_images = 1;
  $show_result = 1;
}
else {
  $search_new_images = 0;
}





The Problem is that PHP can handel multiple select only when you put it in an Array... But the search can´t handel Arrys without modifications... )o:

the only way to get this work is to make a string of the array...

open the search.php and search for:
Code: [Select]
*************************************************************************/
and replace it with:
Code: [Select]
*************************************************************************/

if ($search_keywords_multi){
$HTTP_POST_VARS['search_keywords'] = implode(" ", $search_keywords_multi);
$HTTP_GET_VARS['search_keywords'] = implode(" ", $search_keywords_multi);
}
if ($search_keywords_check){
$HTTP_POST_VARS['search_keywords'] = implode(" ", $search_keywords_check);
$HTTP_GET_VARS['search_keywords'] = implode(" ", $search_keywords_check);
}
$HTTP_POST_VARS['search_keywords'] .= " ".$HTTP_GET_VARS['search_keywords_check'];
$HTTP_POST_VARS['search_keywords'] .= " ".$HTTP_GET_VARS['search_keywords_multi'];

Then you must use a select multiple box like this:

Code: [Select]
<select size="4" class="input" name="search_keywords_multi[]" multiple>
        <option value="Keyword1">Keyword1</option>
        <option value="Keyword2">Keyword2</option>
        <option value="Keyword3">Keyword3</option>
</select>

Then you must use  checkboxes like this:
Code: [Select]
<input type="checkbox" name="search_keywords_check[]" value="Keyword1">
<input type="checkbox" name="search_keywords_check[]" value="Keyword2">
<input type="checkbox" name="search_keywords_check[]" value="Keyword3">


@TIMT
I have done this on your Test Site and it works well... (o:

Offline nameless

  • Full Member
  • ***
  • Posts: 147
    • View Profile
Re: [MOD] Custom Search Template
« Reply #12 on: November 25, 2008, 01:07:06 AM »
nice one
i'd love to know how can i make more than one Dropdown

to be like this
http://www.gsmarena.com/search.php3