PDA

View Full Version : Search Addon - here it is


amalydia
05-28-2005, 02:35 AM
ever wanted a search addon, which searches headline (title) and body (description) of your database (table pixelpost)

just add <SEARCH_BOX> where you want the searchbox

and <SEARCH_RESULTS> in a new template file named search_template.php


and here comes the code for search.php


<?php
/*

Requires Pixelpost version 1.4 or newer
Search_ADDon 0.1

Written by: Mirko Theophil aka amalYdia
http://www.amalydia.de

Pixelpost www: http://www.pixelpost.org/

License: http://www.gnu.org/copyleft/gpl.html

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
================================================== ==========================

NEW TAGS:
<SEARCH_RESULT>
<SEARCH_BOX>
*/

$addon_name = "Search (for PP v1.4)";
$addon_version = "0.1";
$addon_description = "$attention_call Simple Search ADDon for PP1.4.1 by amalydia.de";

//-------------------------------- SEARCH BOX
$search_box = "<form method='post' action='index.php?x=search' name='searchform' >
<label><input type='text' name='q' class='input' value='suche' /></label>
<input type='submit' value='GO' class='commentbutton' />";
$tpl = str_replace("<SEARCH_BOX>",$search_box,$tpl);

//-------------------------------- SEARCH FUNCTION
$query = mysql_query('SELECT * '
. ' FROM `'.$pixelpost_db_prefix.'pixelpost` '
. ' WHERE (`headline` '
. ' LIKE \'%'.$q.'%\' OR `body` '
. ' LIKE \'%'.$q.'%\') LIMIT 0, 30');

$i=0;
while( $row=mysql_fetch_array($query) )
{
$image_name = $row['image'];
$image_title = pullout($row['headline']);
$image_id = $row['id'];
$image_title = htmlspecialchars($image_title,ENT_QUOTES);
$image_thumbnail_no_link = "<img src='thumbnails/thumb_$image_name' alt='$image_title' title='$image_title' />";
$search_links .= "<a href='$showprefix$image_id'>$image_thumbnail_no_link</a>";
$i++;
}

if(!$search_links) {
$search_links = "Keine Ergebnisse zum Suchbegriff <i>".$q."</i> gefunden!<br/><br/>";
}

$tpl = str_replace("<SEARCH_RESULTS>",$search_links,$tpl);
?>

raminia
05-28-2005, 07:32 AM
Did you see this topic?
http://pixelpost.org/forum/viewtopic.php?t=626&postdays=0&postorder=asc&start =0

there is already two versions of search addon. Does your search addon do similar job? what are the differences.

If you can provide a more flexible search addon with combiniation of these addons, it would be great.

amalydia
05-28-2005, 11:40 AM
i justr wanted to simplify the search progress and the appereance of the results.. thats why i gave this addon the version number 0.1 :-)

steff
05-28-2005, 09:39 PM
after some trial&error, I was able to get it to work!
thank you! :)
the new file should be called search_template.html (not search_template.php) and should be placed into the /templates/your-template-name folder

blinking8s
05-28-2005, 10:06 PM
I just dont understand the need for a search feature on a "photoblog" it sort of goes against the entire idea behind the system...

lol

steff
05-28-2005, 10:30 PM
well, if someone finds my blog thru google, while searching -say- Bologna pics, he'll find just one pic.
then he could search into my photoblog for "Bologna" and he finds 5 more pictures! :)

blinking8s
05-28-2005, 10:39 PM
the odds are so insanely remote though...and 95% of the photoblogs containing search features that i come across i get no results back on my query, you truly have to have a ton of content/keywords covered for this to directly benifit a visitor in any way possible.

ctranter
05-29-2005, 05:49 PM
can you get this to return keywords that are categories as well?

ctranter
05-29-2005, 05:52 PM
Ideally it would be good to have an option when you upload a new image to have a field where you can enter keywords specific to that image into and it will save those, separate to the main description. And the search feature will uses that to pull out images.

amalydia
05-30-2005, 07:01 AM
you don't have to make a new table-field.. just remove the description from your template and add your keaywords in this field... the field won't be shown, but will be used for search progress

ctranter
05-30-2005, 11:40 AM
Mmm but I want the description as well :P.