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: New Searchbox if there a no results  (Read 3604 times)

0 Members and 1 Guest are viewing this topic.

flasyn

  • Contributor
  • Coppermine newbie
  • ***
  • Country: de
  • Offline Offline
  • Posts: 19
    • dokufoto.de
New Searchbox if there a no results
« on: January 26, 2006, 09:36:53 pm »

Hi,

I am trying to make the searchfunction easier for users. If there are no matches I would like to send out the standard message "No image to display" and put a new searchbox beneath.

I guess I have to edit functions.inc.php in  line 1704 or 1869 (right?) and put in the code for a new search box. Is there anyone who can assist me?

Code: [Select]
        } else {
                theme_no_img_to_display($album_name);
        }

Tkank you!

Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: New Searchbox if there a no results
« Reply #1 on: January 27, 2006, 02:54:25 am »

You could actually do this with a plugin, I'm pretty sure, so you don't have to modify the core code.  My plugin "Search Album Title & Description" on the plugins board adds on a Search Albums table to the search results page, so you could use the same hook to add in the search box.  (The plugin also replaces the search page with a custom one, but that's not related to what you need.)

Take a look at the plugin.  If you prefer to simply modify the core script, I can lend a hand, when I have a little more time.
Logged

flasyn

  • Contributor
  • Coppermine newbie
  • ***
  • Country: de
  • Offline Offline
  • Posts: 19
    • dokufoto.de
Re: New Searchbox if there a no results
« Reply #2 on: January 27, 2006, 11:53:59 am »

Thanks Paver for helping out.  ;)  I didn't know about the plugin. I will take a look at it.
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: New Searchbox if there a no results
« Reply #3 on: January 27, 2006, 01:25:03 pm »

I take back my previous statement.  Well, what I mean to say is that sure, you could do it with a plugin, but you could also do it in your theme.php, which is not modifying the core code, so that's a very reasonable way to do it.

What you'll be doing is creating a custom theme_no_img_to_display() function.  Copy the code below into your theme.php:
Code: [Select]
function theme_no_img_to_display($album_name)
{
    global $lang_errors, $template_no_img_to_display;

    static $template = '';
    static $spacer;

    if ((!$template)) {
        $template = $template_no_img_to_display;
        $spacer = template_extract_block($template, 'spacer');
    }

  // put mod here for quick search box before "no image to display" table

    $params = array('{TEXT}' => $lang_errors['no_img_to_display']);
    starttable('100%', $album_name);
    echo template_eval($template, $params);
    endtable();

  // put mod here for quick search box afer "no image to display" table
}

This is the sample code from sample/theme.php that is used to customize the "no image to display" table, except I added in 2 comment lines that tell you where to put the code for adding a quick search box.  This function is used whenever an album has no image to display, either for an empty album, or an empty search results meta-album.  Since it's used for both, you need to check whether this function is being called for an empty search results reason and not for an empty regular album.

To add a quick search box, choose whether you want this above or below the "no image to display" table, and put the code below at the appropriate line:
Code: [Select]
  // mod begin - add quick search box
   if ($_POST['search'] || $_GET['search']) {

echo <<<EOT
<form method="get" action="thumbnails.php" name="searchcpg">
            <input type="hidden" name="album" value="search" />
            <input type="hidden" name="type" value="full" />
            <input type="input" name="search" maxlength="255" value="" class="textinput" />
            <input type="submit" value="Quick Search" />
&gt; <a href="search.php">Advanced Search</a>
          </form>
          <script language="javascript" type="text/javascript">
          <!--
          document.searchcpg.search.focus();
          -->
          </script>
EOT;
    }
  // mod end - add quick search box

Warning:  If you want to use my Search Album plugin, you need to modify the "Advanced Search" link above to point to "index.php?file=search_album/search" instead of "search.php".  I just realized my plugin breaks the regular search form and so if you link to it, an error will occur.  I will fix that for my plugin, but for now, please pick the correct link for the "Advanced Search" link, or just delete that line if you don't want it.  So I don't need to add a post to this thread in the future, version 1.02 of the Search Album plugin has this problem.  I'll make sure to put the fix into the next release, so look in the plugin thread for the version number to determine if you need to change this code or not.  Ideally, you don't want to manually change anything when activating or deactivating a plugin.  Otherwise, what's the point of having a plugin as opposed to a hack?   :P
Logged

flasyn

  • Contributor
  • Coppermine newbie
  • ***
  • Country: de
  • Offline Offline
  • Posts: 19
    • dokufoto.de
Re: New Searchbox if there a no results
« Reply #4 on: January 27, 2006, 05:16:08 pm »

Wow, thanks a lot!  ;)

I'll implement that.

[whisper-mode: on] I know I shouldn't be saying that and I hope no one accuses me of highjacking the 1.4 forum, but I'm still using 1.3 (extremly modified and not open to public, thus no risk concerning the security leaks in 1.3).  I just saw that the code for the  searchfunction is still the same in 1.4 and thought that other users want to offer their users the advanteges of an easier search. But your plugin is certainly the easiest and most convenient solution. [whisper-mode: off]
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: New Searchbox if there a no results
« Reply #5 on: January 27, 2006, 05:26:41 pm »

but I'm still using 1.3
Why did you post your thread on this board then?

I just saw that the code for the  searchfunction is still the same in 1.4
no, it isn't - it has changed completely. How do you come to this conclusion?
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: New Searchbox if there a no results
« Reply #6 on: January 27, 2006, 10:13:49 pm »

@flasyn: You don't have to whisper about using 1.3.  It's perfectly acceptable to stick with 1.3 and it will be supported.  But please use the appropriate boards for asking questions about issues in 1.3.

My answer was for 1.4.  If you want to ask the same question for 1.3, please start a thread on the analogous section of the 1.3 board.
Logged
Pages: [1]   Go Up
 

Page created in 0.022 seconds with 20 queries.