aengusm
Forum Replies Created
-
Forum: Plugins
In reply to: [Login No Captcha reCAPTCHA] reCaptcha before login pageI should add, I know that is totally weird, why have two captcha, I have been asked to do that…I’ll convince them otherwise at a later date.
Forum: Themes and Templates
In reply to: [Magnus] Tile and post header imageahhhh, ignore this, I just realised I need to set “Featured Image” within the post.
AengusForum: Plugins
In reply to: [Plugin: NextGen Gallery] add search possibility also to pictures ! how toI’ve blog’d how I do my search noting I just search images;
https://blog.aengusm.com/?p=253
I’ve added the code from my pages to the post.
Hope it can help some?
Cheers,
AengusAh I see, I’m getting a post back with pics not just pics.
What I’ve done is just to return pics, I’ve removed the post component from search.php (see above and compare with yours).
Not sure what you need to do but suspect answer is the search.php syntax.I did my original adjustments based on Psykotik’s post;
https://www.ikiru.ch/blog/2008/how-to-add-a-search-function-for-nextgen-gallery-wordpress-plugin.A quick interim fix for you is maybe to setup a “Search Pics” “Search blog” using a second search.php?
Aengus
Hi Ron,
just searched on your site for Elk and got a couple of dozen shots back…is your issue fixed?
Glad above was of some help at least!
Cheers,
AengusGlad you got sorted Gary and thanks for that great link.
Aengus
Forum: Plugins
In reply to: [Plugin: NextGen Gallery] add search possibility also to pictures ! how toThis post maybe of assistance with regard to search and 1.0;
https://www.ads-software.com/support/topic/230905?replies=1#post-944495
Cheers,
Aengus
Hi Tom,
all Ok with me and I have spent a bit of time testing, however, I only search the gallery tags and not the blog, as you can see here I use a dedicated search page solely for the images.
So my search.php would look very different to yours (and you should have extra components in your functions.php)…this my search.php;
<?php get_header(); ?> <div id="content"> Search results; <?php if(is_search()) { $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, '6'); // put the number of pictures by row you want, if you don't want "4" if ($nggpictures) { echo "<h2></h2>"; echo $nggpictures; } } } ?> Want to refine or do another Search? <?php include (TEMPLATEPATH . '/searchform.php'); ?> </div> <?php get_sidebar(); ?> <!-- The main column ends --> <?php get_footer(); ?>
As I understand it, NextGen is heading towards integrating the NextGen tags with the WordPress tags so without looking too hard into it, I’m not surprised to hear of “Double” returns, whereas the code above is really for Pic Gallery search only.
The whole idea of the UNION section is to search not just the tags but also the pic title and the alt/Description component and the object_id component is part of what links the components together.
Hope above makes sense?
Great Pics by the way…but I have to tell you, nothing beats the NYE fireworks down here in Sydney ??
Cheers,
Aengus
Here we go, lets hope this posts OK (full contents of my functions.php);
<?php if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Sidebar Top', 'before_widget' => '', 'after_widget' => '', 'before_title' => '<h2>', 'after_title' => '</h2>', )); ## Function to do searchs on gallery pics from NextGen Gallery plugin ## ## 2 vars : (1) $keywords (usually coming from the standard search query from wordpress) ## (2) $numberPicCol (number of pic by row, if null it takes 4 ) function ngg_get_search_pictures ($keywords, $numberPicRow = NULL) { global $wpdb; $count=1; if (!$numberPicRow) { $numberPicRow = "4"; } $nngquery = " SELECT pid,description,alttext FROM wp_ngg_pictures WHERE MATCH (description, filename, alttext) AGAINST ('*$keywords*' IN BOOLEAN MODE) AND exclude = '0' UNION SELECT pid,description,alttext FROM wp_ngg_pictures, wp_terms, wp_term_relationships WHERE pid = object_id and term_id = term_taxonomy_id and MATCH (name) AGAINST ('*$keywords*' IN BOOLEAN MODE) AND exclude = '0' "; $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="gallery'.$pic[pid].'">'; $out .= '<img class="ngg-gallery" style="border: .1em solid #FFFFFF" src="'.nggGallery::get_thumbnail_url($pic[pid]).'" alt="'.stripslashes($pic[alttext]).'" title="'.stripslashes($pic[alttext]).'" />'; $out .= "</a>\n"; if ($count == 0) { $out .= ""; } ++$count; $count%=$numberPicRow; } return $out; }; ?>
Here you go Tom, compliments of the girlfriend again ??
testing not 100% completed…but looking good…
UNION
SELECT pid,description,alttext
FROM wp_ngg_pictures, wp_terms, wp_term_relationships
WHERE pid = object_id and term_id = term_taxonomy_id and
MATCH (name) AGAINST (‘*$keywords*’ IN BOOLEAN MODE)
AND exclude = ‘0’Aengus
I can see the new relationships, just busy and wouldn’t get to trying for another 24 hours, involves wp_term_relationships table and object_id / term_taxonomy_id and term_id in wp_terms table.
We’ll get there!
Aengus
Hi Tom,
My search was returning absolutely no results and no error, as if there was no results, so stage one have made the following change within functions.php (root of theme)….
hashed out the union…
##UNION
##SELECT pid,description,alttext
##FROM wp_ngg_pictures, wp_ngg_tags, wp_ngg_pic2tags
##WHERE pid = picid and tagid = id and
##MATCH (name) AGAINST (‘*$keywords*’ IN BOOLEAN MODE)
##AND exclude = ‘0’and in the following lines changed nggallery to nggGallery;
‘.nggGallery::get_image_url($pic[pid]).’
and on next line;
‘.nggGallery::get_thumbnail_url($pic[pid]).’
(note no change to ngg-Gallery);This first step has search returns for keywords in the Alt/title and description fields, I’ll get to the tags in the next few days.
I also tried re-implementing (is that a word?) the standard wp search pages assuming that with the tags integrated into the wp-tax that may return results but no joy…so I’ll look at mapping the old ngg_tags and pics2tags…….unless someone else has a better suggestion?
Aengus
sorted…found them under wp_terms
Forum: Plugins
In reply to: [Plugin: NextGen Gallery] add search possibility also to pictures ! how toG’day Marlon,
sent you an email with some files attached.
Good luck!
Aengus
Forum: Plugins
In reply to: [Plugin: NextGen Gallery] add search possibility also to pictures ! how toAh, good point about the blog tags! I should have added, I only want search for pictures, no blog search so I removed that component from the search.php.
Its all a good start for NextGen Search!
Aengus