search box in CPG search box in CPG
 

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]

Main Menu

search box in CPG

Started by marecki, September 11, 2009, 02:41:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

marecki

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)" ?

Nibbler

Easiest way would be to change


<input type="hidden" name="type" value="full">


to


<input type="hidden" name="type" value="AND">


and


method="get"


to


method="post"

blueberg

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

blueberg

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.

<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 "post" should the action have been changed as well? Please forgive my ignorance in these matters  ;D
http://www.birdmarks.com/coppermine


Nibbler

Add another hidden input like this


<input type="hidden" name="keywords" value="on">

blueberg

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.

<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

blueberg

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
<form method="post" action="http://birdmarks.com/coppermine/thumbnails.php" name="searchcpg">

TO

<form method="post" action="http://birdmarks.com/coppermine/thumbnails.php" name="searchcpg1">

IN THIS

<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:


<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

Joachim Müller

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.