<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PIRZADEH.se &#124; Nima Pirzadeh &#187; PHP</title>
	<atom:link href="http://www.pirzadeh.se/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pirzadeh.se</link>
	<description>En kreativ kommunikationsbyrå. Nyfikenheten är vårt viktigaste arbetsredskap.</description>
	<lastBuildDate>Sat, 28 Jan 2012 04:32:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to add a search function to NextGen gallery wordpress plugin with WordPress 2.7 and Nextgen gallery 1.x</title>
		<link>http://www.pirzadeh.se/how-to-add-a-search-function-to-nextgen-gallery-wordpress-plugin-with-wordpress-27-and-nextgen-gallery-1x/2009/06/10/</link>
		<comments>http://www.pirzadeh.se/how-to-add-a-search-function-to-nextgen-gallery-wordpress-plugin-with-wordpress-27-and-nextgen-gallery-1x/2009/06/10/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 15:20:42 +0000</pubDate>
		<dc:creator>Nima Pirzadeh</dc:creator>
				<category><![CDATA[Mjukvara]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.pirzadeh.se/?p=497</guid>
		<description><![CDATA[I found this page, but didnt work,. i have made some changes on the code. I hope this will fix your problem. Add this on your search.php $search = $wp_query->get('s'); $keywords = preg_replace('/\+/',' ',$search); if (function_exists ('ngg_get_search_pictures')) { // function from functions.php $nggpictures = ngg_get_search_pictures($keywords, ''); // put the number of pictures by row you ...]]></description>
			<content:encoded><![CDATA[<p>I found this <a href="http://www.ikiru.ch/blog/2008/how-to-add-a-search-function-for-nextgen-gallery-wordpress-plugin/comments-page-2" target="_blank">page</a>, but didnt work,. i have made some changes on the code. I hope this will fix your problem.</p>
<p><strong>Add this on your search.php</strong></p>
<pre lang="PHP">$search = $wp_query->get('s');
	$keywords = preg_replace('/\+/',' ',$search);
	if (function_exists ('ngg_get_search_pictures')) {  // function from functions.php
		$nggpictures = ngg_get_search_pictures($keywords, ''); // put the number of pictures by row you want, if you don't want "4"

		if ($nggpictures) {
			echo "
<h2>Bilder</h2>

";
			echo $nggpictures;
		}
	}</pre>
<p><strong>Add this to your functions.php</strong></p>
<pre lang="PHP">
/**
** Function to do searchs on gallery pics from NextGen Gallery plugin
**
** @keywords		keywords, usually gave by the standard search query from wordpress
** @numberPicCol	number of pic by row. If null, it takes 4 by default
*/
function ngg_get_search_pictures ($keywords, $numberPicRow = NULL) {
	global $wpdb;
	$count=1;
	if (!$numberPicRow) { $numberPicRow = "4"; }

	$nngquery = $wpdb->prepare( "
				SELECT pid,description,alttext
				FROM " .$wpdb->prefix. "ngg_pictures
				WHERE MATCH (description, filename, alttext) AGAINST (%s IN BOOLEAN MODE)
				AND exclude != 1
				","*".$keywords."*");

	$pictures = $wpdb->get_results($nngquery, ARRAY_A);

	if ($pictures) foreach($pictures as $pic) { 

		$out .= '

<a href="'.nggGallery::get_image_url($pic[pid]).'" title="'.stripslashes($pic[description]).'" class="thickbox" rel="singlepic'.$pic[pid].'">';
		$out .=  '<img src="'.nggGallery::get_thumbnail_url($pic[pid]).'" alt="'.stripslashes($pic[alttext]).'" title="'.stripslashes($pic[alttext]).'" border="0" />

';
		$out .=  "</a>\n"; 

		if ($count == 0) {
			$out .= "";
		}

		++$count;
		$count%=$numberPicRow;
	}
	return $out;
};
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.pirzadeh.se/how-to-add-a-search-function-to-nextgen-gallery-wordpress-plugin-with-wordpress-27-and-nextgen-gallery-1x/2009/06/10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

