If you are using a plugin like Evil_Blog or Additional_Pages you have the problem, that pages created with theses plugins are not included in the standard Piwigo search.
In other words: If you have created a kind of blog, your blog articles are not found within the Piwigo search.
One solution might be to include a external search engine, but probably those external solutions have some limitations (adding ads, limited indexing etc.).
Here is another way how you can add a 'page search' to your Piwigo gallery:
Before we start:
Now let's go:
Step 1 - Creating the search form:
The style adjustments you see below are created to fit into the 'Stripped' template. If you use a different template you will have to modifiy it. Also you might have to change the german descriptions I have used.
In an editor like notepad++ create a html page with the content shown below:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="en" http-equiv="Content-Language" /> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Search</title> <style type="text/css"> .auto-style3 { color: #999999; } input.black_text { background: #666666; color: #d9d9d9; border:1px solid #999999; } .design1{ background-color:#3f3f3f; border:1px solid #606060; color:#d9d9d9; padding:5px; } .design1:hover{ background-color:#666666; border:1px solid #606060; color:#d9d9d9; padding:5px; } </style> </head> <body bgcolor="#202020"> </p> <form action="/search/results.php" method="post"> <input name="searchitem" type="text" class="black_text" size="45" value="Enter Search" style="height: 20px" onFocus="if(this.value=='Enter Search') this.value=''"/><span class="auto-style3"> <br /> <br /> </span><input class="design1" name="submit" type="submit" value="Start PageSearch" style="width: 147px; height: 40px" /> </form> <p> </p> <p> </p> </body> </html>
Save the html page as:
search.html
Create a new folder within your Piwigo installation named:
search
and upload the search.html you have created to this folder.
Step 2 - Including it into Piwigo
Create a new page with the Additional_Pages plugin and name this page something like 'page search'.
Have a look in the editor menu bar for the IFrame icon and add the search.html as the iframe source.
Change the properties of the iframe to fit your needs. My source code for the iframe looks like:
<iframe frameborder="0" height="1000" scrolling="no" src="http://yourdomain/search/search.html" width="800"></iframe></p>
You will need to modify 'yourdomain' to your domain name
Step 3 - the results page
Note: You will change the parameters for $Verbindung to your data.
You might also want to change the german description, page title etc.
We will search the database table 'evil_blog' here. You might need to change it too.
<head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Pixel Wonders | Search Results</title> </head> <body bgcolor="#202020"> <style type="text/css"> a:link {color:#d9d9d9;} a:visited {color:#999999;} a:hover {color:#999999;} a:active {color:#d9d9d9;} </style> </p> <?php $sconnetcion = mysql_connect("hostname", "username","password"); mysql_select_db("databasename") or die ("Die Datenbank existiert nicht."); $searchitem = null; // Reset Search $searchitem = $_POST['searchitem']; // validate searchitem $searchitem = mysql_real_escape_string(stripslashes($searchitem)); // proof searchitem if(!isset($searchitem) || empty($searchitem)) die ("<font color='red'>Nothing entered.</font>"); // sql statement erstellen $srequest = sprintf("SELECT * FROM `evil_blog` WHERE `%s` = '%s'", $feld, $searchitem); $srequest = sprintf("SELECT * FROM `evil_blog` WHERE `header` LIKE '%s'", '%'.$searchitem.'%'); $srequest = sprintf("SELECT * FROM `evil_blog` WHERE `text` LIKE '%s'", '%'.$searchitem.'%'); $sresult = mysql_query($srequest); echo '<table>'; echo "<tr><td><font color='#d9d9d9'>Search Results for: <b>".$_POST["searchitem"]."</b>:</font></td></tr>"; if(mysql_num_rows($sresult) > 0) { while($row = mysql_fetch_object($sresult)) { echo '<tr>'; echo "<td><a href=\"http://yourdomain/?/blog/id/$row->id\" target=\"_parent\">$row->header</a></td>"; echo '</tr>'; } } else { echo "<font color='red'>For your search: '<b>".$_POST["searchitem"]."</b>' nothing was found.</font>"; } echo '</table>'; mysql_close($sconnection); ?> </body> </html>
Save the file as results.php and upload it to the search folder created before.
Important:
Take the results.php as a starting point for creating your own page search.Depending on rewrite rules or settincs in the local file editor (php extension, question mark in urls etc) you will have to make adjustmens to get it working!
Especially the display of the search results is depending on the adjustments you have made before. The results table:
echo "<td><a href=\"http://yourdomain/blog/id/$row->id\" target=\"_parent\">$row->header</a></td>"; echo '</tr>';
is an example for this.
Hint:
Simply look at the url displayed for your evil_blog and adjust the settings.
Finally:
Again: Following the steps decribed here will be at your own risk!
The files created here will not be updated automatically when a new Piwigo release comes out.
I am pretty sure that a search described here is not the non-plus-ultra-solution, so take it as it is:
Only one possibility how you can extend the Piwigo search.
By modifying the search.tpl of the stripped template you can embedd the search form into the search template as I did it on my site:
http://www.pixel-wonders.de/search.php
Just have a look in the search.tpl file in the stripped folder.
You can also add a 'New search' button to the results.php which reloads the search form by adding:
<a href="http://www.yourdomain/index/page/name_of_additional_page" target="_parent">Neue Suche</a>
Just after the style definition (around line 20) in the results.php
Important:You should really consider to store the database connection data in a separate file and include it with the include_once command!!
Cheers
Ralf
If you have any questions or enhancements please feel free to use the contact form on:
http://www.pixel-wonders.de