How do I get my search button to run Coppermine's search function? How do I get my search button to run Coppermine's search function?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

How do I get my search button to run Coppermine's search function?

Started by matheso, December 28, 2014, 09:20:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

matheso

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


matheso

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.

<form action="search.php" method="get">
  <input type="submit" value="Search now!">
</form>

allvip

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?

allvip

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.

allvip


Joe Carver

Quote from: matheso on December 28, 2014, 09:20:35 PM
... 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


Αndré

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
Quotethumbnails.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).

allvip

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?

Αndré

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.

matheso

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

Αndré

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?

Αndré


matheso

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.


matheso


matheso

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

<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...  ???

Αndré

Change
<input type="text" maxlength="70" placeholder=" Search for anything! Vintage+war, animals, city scene ..." id="name" name="name">
to
<input type="text" maxlength="70" placeholder=" Search for anything! Vintage+war, animals, city scene ..." id="name" name="search">

and add
<input type="hidden" name="album" value="search" />
<input type="hidden" name="type" value="OR" />

matheso

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:

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

Αndré

Sorry, I overlooked that. You need to use method="get"
instead of "post".

matheso