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: How do I get my search button to run Coppermine's search function?  (Read 5899 times)

0 Members and 1 Guest are viewing this topic.

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91

I've included a custom button on my page, and when someone clicks it I want it to perform the same function as clicking Coppermine's  submit button.

In other words, my website found here www.taskbasket.net/gallery/

has a search box, and a blue search button. Let's say we type in "forest" and then click the search button. I want it to go *directly* to the results... basically as if we had gone to http://taskbasket.net/gallery/search.php  and typed in "forest".   Meaning, I don't want users to be shown "Newer than", "older than", "match all words" options... I simply want my search button to SUBMIT the search fully, and load the results.

Is this possible? Thank you

Logged

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91
Re: How do I get my search button to run Coppermine's search function?
« Reply #1 on: December 28, 2014, 09:22:52 pm »

If I use the following HTML, it will load search.php once the button is clicked.... but I want RESULTS to be shown, not the search.php page.

Code: [Select]
<form action="search.php" method="get">
  <input type="submit" value="Search now!">
</form>
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: How do I get my search button to run Coppermine's search function?
« Reply #2 on: December 28, 2014, 11:02:04 pm »

Is more simple to use search scripts: http://www.thefreecountry.com/php/site-search-engine-scripts.shtml.

You build it yourself or you use a script, plugin etc?
If is a script, witch one?
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: How do I get my search button to run Coppermine's search function?
« Reply #3 on: December 28, 2014, 11:53:41 pm »

If you are trying to use HTML search box like this one: http://www.textfixer.com/tutorials/search-box-examples.php, I do not belive is going to work.

I think HTML search boxes are only for static websites (HTML only), not for dynamic websites (PHP).
You need a search box written in PHP (like the one from my first reply) that connects to your coppermine database and makes a search (query) in table pictures for title, keywords, filename, caption, thumb image.
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: How do I get my search button to run Coppermine's search function?
« Reply #4 on: December 29, 2014, 12:19:56 am »

Is more simple to use search scripts: http://www.thefreecountry.com/php/site-search-engine-scripts.shtml.

Sorry, that's a search engine, not a PHP search box.
Search in Google PHP search box.
Logged

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1545
  • aka 'i-imagine'
    • Home Page
Re: How do I get my search button to run Coppermine's search function?
« Reply #5 on: December 29, 2014, 12:58:03 am »

... I simply want my search button to SUBMIT the search fully, and load the results.

Is this possible? Thank you

Yes, but you need to also use another cpg file: include/search.inc.php.

See / use this plugin that puts a search box on the home page only.
It should show you what needs to be done. Look in codebase.php

Home Page Search v1.0

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91
Re: How do I get my search button to run Coppermine's search function?
« Reply #6 on: December 29, 2014, 04:54:21 am »

I've decided to use a MySQL solution. Thank you both
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: How do I get my search button to run Coppermine's search function?
« Reply #7 on: December 29, 2014, 08:34:00 pm »

The correct answer would have been, that you need to submit your form to thumbnails.php instead of search.php. You also need to include some hidden values to decide which fields Coppermine should take into account for the search.

E.g. a standard search for "forest" redirects to
Quote
thumbnails.php?search=forest&submit=search&album=search&title=on&newer_than=&caption=on&older_than=&keywords=on&type=AND

so you need at least submit the parameters "search", "album", "type" and at least one of "title", "caption" or "keywords" (maybe also "submit", haven't checked that).
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: How do I get my search button to run Coppermine's search function?
« Reply #8 on: December 29, 2014, 09:19:46 pm »

For @Andre:

Is it possible to take just the search box from search.php with all values (title, caption etc) hidden and add it to themes/theme_name/template.html?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: How do I get my search button to run Coppermine's search function?
« Reply #9 on: December 29, 2014, 09:31:18 pm »

I don't see a reason why this shouldn't work. But I'm quite sure this has already been discussed in several other threads.
Logged

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91
Re: How do I get my search button to run Coppermine's search function?
« Reply #10 on: December 29, 2014, 09:59:51 pm »

Ok, I'll abandon an SQL solution and try what Αndré has suggested.

@Αndré:  How do I include hidden values to send to thumbnails.php, and you said "you need at least submit the parameters "search", "album", "type" and at least one of "title", "caption" or "keywords" (maybe also "submit", haven't checked that)"

Can you supply a sample line of code that would submit the keyword "forest" to be searched against my entire database? I only have one album called ALL FILES.

Thank you
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: How do I get my search button to run Coppermine's search function?
« Reply #11 on: December 29, 2014, 10:11:06 pm »

Do you always want to submit the keyword "forest"? I believe not. Which fields do you want to be searched for your entered search term?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: How do I get my search button to run Coppermine's search function?
« Reply #12 on: December 29, 2014, 10:23:23 pm »

More information here: http://forum.coppermine-gallery.net/index.php/topic,71741.0.html

If you still need support, let me know.
Logged

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91
Re: How do I get my search button to run Coppermine's search function?
« Reply #13 on: December 29, 2014, 10:25:14 pm »

You're right, I want to submit different words depending on what the user types in. I'd like the search to include title,caption and keywords.

So if the user types in "winter forest" .... if the word "winter" is found in an image's caption, it will be shown. Or if only "forest" is found as an image's keyword, that image would be shown.

Logged

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91
Re: How do I get my search button to run Coppermine's search function?
« Reply #14 on: December 29, 2014, 10:25:36 pm »

Just saw your link, will check it out. Thanks
Logged

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91
Re: How do I get my search button to run Coppermine's search function?
« Reply #15 on: December 29, 2014, 10:31:45 pm »

Ok, well I added the lines you suggested in the other thread, so now my html form looks like:

Code: [Select]
<form name="search" method="post" action="thumbnails.php">
  <div>
    <input type="text" maxlength="70" placeholder=" Search for anything! Vintage+war, animals, city scene ..." id="name" name="name">
  </div>
<input type="hidden" name="title" value="on" />
<input type="hidden" name="caption" value="on" />
<input type="hidden" name="keywords" value="on" />
<input type="hidden" name="filename" value="on" />
   
<nav class="cl-effect-2">
<div id="button1">
<a href="#"><span data-hover="Search Now!" onclick="search.submit()">Search Now!</span></a>
</div>
</nav>

     </form>


except when I search "forest" it takes me to http://taskbasket.net/gallery/thumbnails.php    and shows no results, just blank underneath the nav bar. Yet when I use Coppermine's built-in search feature for "forest" it displays the 2 results. I'm clearly missing something...  ???
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: How do I get my search button to run Coppermine's search function?
« Reply #16 on: December 29, 2014, 10:34:55 pm »

Change
Code: [Select]
<input type="text" maxlength="70" placeholder=" Search for anything! Vintage+war, animals, city scene ..." id="name" name="name">to
Code: [Select]
<input type="text" maxlength="70" placeholder=" Search for anything! Vintage+war, animals, city scene ..." id="name" name="search">
and add
Code: [Select]
<input type="hidden" name="album" value="search" />
<input type="hidden" name="type" value="OR" />
Logged

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91
Re: How do I get my search button to run Coppermine's search function?
« Reply #17 on: December 29, 2014, 11:09:16 pm »

I've added what you said, but it still doesn't work and I even tried AND instead of OR.

Can you please check on your end?    taskbasket.net/gallery/index.php     --> use custom search box at top to search for "forest".

The current form code is:

Code: [Select]
<form name="search" method="post" action="thumbnails.php">
  <div>
    <input type="text" maxlength="70" placeholder=" Search for anything! Vintage+war, animals, city scene ..." id="name" name="search">
  </div>
<input type="hidden" name="title" value="on" />
<input type="hidden" name="caption" value="on" />
<input type="hidden" name="keywords" value="on" />
<input type="hidden" name="filename" value="on" />
<input type="hidden" name="album" value="search" />
<input type="hidden" name="type" value="OR" />
   
<nav class="cl-effect-2">
<div id="button1">
<a href="#"><span data-hover="Search Now!" onclick="search.submit()">Search Now!</span></a>
</div>
</nav>

     </form>
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: How do I get my search button to run Coppermine's search function?
« Reply #18 on: December 30, 2014, 09:14:25 am »

Sorry, I overlooked that. You need to use
Code: [Select]
method="get"instead of "post".
Logged

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91
Re: How do I get my search button to run Coppermine's search function?
« Reply #19 on: December 30, 2014, 04:23:47 pm »

That did it! Thanks so much.
Logged
Pages: [1]   Go Up
 

Page created in 0.023 seconds with 19 queries.