Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: search box in CPG  (Read 4249 times)

0 Members and 1 Guest are viewing this topic.

marecki

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
search box in CPG
« on: September 11, 2009, 02:41:11 pm »

I try to add search box in CPG and I've found this topic:
http://forum.coppermine-gallery.net/index.php/topic,19862.0.html

and code:
Quote
<form method="get" action="http://imagetemple.com/gallery/thumbnails.php" name="searchcpg">
<input type="hidden" name="album" value="search">
<input type="hidden" name="type" value="full">
<input type="input" style="width: 90%" name="search" maxlength="255" value="" class="textinput">
<input type="submit" value="Search the file collection" class="button">
</form>

It seems that new box search CPG using "Match any word (OR)", how to change it to "Match all words (AND)" ?
Logged

Nibbler

  • Guest
Re: search box in CPG
« Reply #1 on: September 11, 2009, 04:18:54 pm »

Easiest way would be to change

Code: [Select]
<input type="hidden" name="type" value="full">

to

Code: [Select]
<input type="hidden" name="type" value="AND">

and

Code: [Select]
method="get"

to

Code: [Select]
method="post"
Logged

blueberg

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 48
Re: search box in CPG
« Reply #2 on: January 27, 2010, 08:18:10 pm »

Thanks Nibbler...I will give that a try. By the way...great Paypal Shopping cart mod. It works perfectly for what I needed.
Logged

blueberg

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 48
Re: search box in CPG
« Reply #3 on: January 27, 2010, 08:50:12 pm »

HI Nibbler,

No luck with the new search code. making the changes you suggested, the search now returns NO results for either search term ("black" or "wolf").


Here is how the code looks now.
Code: [Select]

<form method="post" action="http://birdmarks.com/coppermine/thumbnails.php" name="searchcpg">
<input type="hidden" name="album" value="search">
<input type="hidden" name="type" value="AND">
<input type="input" style="background-color: rgb(39,39,39)" name="search" maxlength="255" value="" class="textinput" size="20"><input type="submit" value="Search Here" class="button">
</form>

 

I have left this code in my test site for you to test. I also noticed that this new code takes several seconds longer to parse before returning a "No Images Found" result. Could it be looking in the wrong place? When we changed the method to
Code: [Select]
"post" should the action have been changed as well? Please forgive my ignorance in these matters  ;D
 http://www.birdmarks.com/coppermine

Logged

Nibbler

  • Guest
Re: search box in CPG
« Reply #4 on: January 28, 2010, 12:17:03 am »

Add another hidden input like this

Code: [Select]
<input type="hidden" name="keywords" value="on">
Logged

blueberg

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 48
Re: search box in CPG
« Reply #5 on: January 28, 2010, 04:11:43 pm »

You Rock, Nibbler. That last addition did the trick. Below is the complete form code for an "AND" search form that can be added to any web page.

Obviously, people will have to change the URL in the action part of the form tag to their gallery.

Code: [Select]
<form method="post" action="http://birdmarks.com/coppermine/thumbnails.php" name="searchcpg">
<input type="hidden" name="album" value="search">
<input type="hidden" name="keywords" value="on">
<input type="hidden" name="type" value="AND">
<input type="input"  name="search" maxlength="255" value="" class="textinput" size="20">
<input type="submit" value="Search Here" class="button">

</form>

If I wanted it to also search in titles and descriptions, would I simply add additional hidden fields with "titles" and "descriptions" in their respective name fields and turn their values to "on" ?


Thanks again
Logged

blueberg

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 48
Re: search box in CPG
« Reply #6 on: January 28, 2010, 05:13:20 pm »

One minor tweak with the code.

When added to my template, the search form appeared perfectly in every page. But when I would go to the real search page to do an advanced search, I noticed the small yellow error icon in the lower left of the IE window which means the page loaded...but with errors.

Even though there were errors on the page, it didn't stop the new search form from working properly. When I removed the new search from the template, there were no errors on the page. So the only thing I could think of was that the new search form we made and the advanced search form on that page must share the same form name attribute, "searchcpg"

So I simply changed the name of our new form to "searchpg1"

and that fixed the issue :-)

Change
Code: [Select]
<form method="post" action="http://birdmarks.com/coppermine/thumbnails.php" name="searchcpg">
TO

Code: [Select]
<form method="post" action="http://birdmarks.com/coppermine/thumbnails.php" name="searchcpg1">
IN THIS
Code: [Select]
<form method="post" action="http://birdmarks.com/coppermine/thumbnails.php" name="searchcpg">
<input type="hidden" name="album" value="search">
<input type="hidden" name="keywords" value="on">
<input type="hidden" name="type" value="AND">
<input type="input"  name="search" maxlength="255" value="" class="textinput" size="20">
<input type="submit" value="Search Here" class="button">
</form>

  So final version of the code is this:

Code: [Select]
<form method="post" action="http://birdmarks.com/coppermine/thumbnails.php" name="searchcpg1">
<input type="hidden" name="album" value="search">
<input type="hidden" name="keywords" value="on">
<input type="hidden" name="type" value="AND">
<input type="input"  name="search" maxlength="255" value="" class="textinput" size="20">
<input type="submit" value="Search Here" class="button">
</form>

Again....Be sure to point the form action to the location of your "thumbnails.php" in YOUR coppermine root.

http://www.birdmarks.com/coppermine


Thanks again, Nibbler
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: search box in CPG
« Reply #7 on: January 28, 2010, 05:19:10 pm »

That's plain HTML/DOM: there mustn't be two elements on a page with the same name. Renaming the form indeed does the trick. Thanks for resolving that for the benefit of others. You might even add a little more magic to your custom search form: spice it up (using PHP), performing a little if/then magic, checking the file name: if you're on the actual "big" search page, i.e. if the visitor has deliberately chosen to use the advanced search, don't display your custom, "simple" search field.
Logged
Pages: [1]   Go Up
 

Page created in 0.029 seconds with 19 queries.