Ticket #936 -> Revisión de la ejecución de búsquedas. No salen resultados al buscar un grupo.

git-svn-id: https://192.168.0.254/svn/Proyectos.ASong2U_Web/trunk@47 cd1a4ea2-8c7f-e448-aada-19d1fee9e1d6
This commit is contained in:
David Arranz 2012-07-28 17:28:54 +00:00
parent 5831aa1459
commit d468fb1ef6
10 changed files with 315 additions and 19 deletions

View File

@ -21,6 +21,11 @@ if ( !defined( 'DEDICATION_CATEGORY_SLUG' ) )
/* * ************************* Concerts Information ********************* */
if ( !defined( 'MUSICNEWS_CATEGORY_SLUG' ) )
define( 'MUSICNEWS_CATEGORY_SLUG', 'music-news' );
/* * ************************* Concerts Information ********************* */
if ( !defined( 'CONCERTS_CATEGORY_SLUG' ) )
define( 'CONCERTS_CATEGORY_SLUG', 'concerts' );
@ -78,6 +83,7 @@ if ($theme_reviews_follow == "0") {
// BuddyPress Functions
if (function_exists('bp_is_active') && file_exists(ghostpool_bp . 'functions-buddypress.php')) {
require_once(ghostpool_bp . 'functions-buddypress.php');
require_once(ghostpool_bp . 'search-buddypress.php');
}
/* * ************************* Flags img function *********************** */
@ -474,23 +480,27 @@ add_filter('request', 'gp_posts_per_page');
/* * ************************* Search Criteria ************************** */
function SearchFilter($query) {
require(ghostpool_inc . 'options.php');
if (!is_admin()) {
if ($query->is_search) {
if ($theme_search_criteria == "Review Posts Only") {
$query->set('meta_key', 'ghostpool_post_type');
$query->set('meta_value', 'Review');
} elseif ($theme_search_criteria == "All Posts") {
$query->set('post_type', 'post');
}
$query->set('meta_query', array(
'relation' => 'OR',
array(
'key' => 'ghostpool_dedication_artist',
'value' => $query->query_vars['s'],
'compare' => 'LIKE'
),
array(
'key' => 'ghostpool_dedication_song',
'value' => $query->query_vars['s'],
'compare' => 'LIKE'
)
));
}
return $query;
}
}
add_filter('pre_get_posts', 'SearchFilter');
//add_filter('pre_get_posts', 'SearchFilter');
/* * ************************* Shortcode Empty Paragraph Fix ************************** */

View File

@ -16,6 +16,8 @@
</head>
<?php if(is_search()) : $gp_settings['skin'] .= ' bp-wrapper'; endif; ?>
<![if !IE]>
<body <?php body_class($gp_settings['browser'].' '.$gp_settings['layout'].' '.$gp_settings['skin']); ?>>
<![endif]>
@ -25,7 +27,7 @@
<!--[if lt IE 9]>
<body <?php body_class('ie8 '.$gp_settings['browser'].' '.$gp_settings['layout'].' '.$gp_settings['skin']); ?>>
<![endif]-->
<!--Begin Page Wrapper-->
<div id="page-wrapper">
@ -42,7 +44,7 @@
<!--End Logo-->
<?php if(is_user_logged_in()) { ?>
<?php global $bp, $current_user; get_currentuserinfo(); ?>
<div class="login-name"><?php echo $current_user->display_name; ?> (<a href="<?php echo wp_logout_url(); ?>"><?php _e( 'Logout', 'buddypress' ) ?></a>)</div>
<div class="login-name"><?php echo $current_user->display_name; ?></div>
<? } ?>
<?php if ( is_user_logged_in() ) : ?>
@ -62,6 +64,7 @@
<li><a title="<?php _e( 'Members', 'gp_lang' ); ?>" class="friends" href="<?php echo bp_get_members_directory_permalink(); ?>"><span><?php _e( 'Members', 'gp_lang' ); ?></span></a></li>
<li><a title="<?php _e( 'Groups', 'gp_lang' ); ?>" class="groups" href="<?php echo bp_get_groups_directory_permalink(); ?>"><span><?php _e( 'Groups', 'gp_lang' ); ?></span></a></li>
<li><a title="<?php _e( 'Profile', 'gp_lang' ); ?>" class="profile" href="<?php if(function_exists('bp_is_active')) { echo $bp->loggedin_user->domain; } else { echo get_author_posts_url(get_the_author_id()); } ?>"><span><?php _e('Profile', 'gp_lang'); ?></span></a></li>
<li><a title="<?php _e( 'Logout', 'gp_lang' ); ?>" class="logout" href="<?php echo wp_logout_url(); ?>"><span><?php _e('Logout', 'gp_lang'); ?></span></a></li>
</ul>
<?php endif; ?>

View File

@ -0,0 +1,183 @@
<?php
function bpmag_remove_search_dropdown($select_html) {
return '';
}
// Remove Buddypress search drowpdown for selecting members etc
add_filter("bp_search_form_type_select", "bpmag_remove_search_dropdown");
remove_action('init', 'bp_core_action_search_site', 5); //force buddypress to not process the search/redirect
add_action('init', 'bp_buddydev_search', 10); // custom handler for the search
function bp_buddydev_search() {
global $bp;
if ($bp->current_component == BP_SEARCH_SLUG)//if thids is search page
bp_core_load_template(apply_filters('bp_core_template_search_template', 'search-single')); //load the single searh template
}
add_action("advance-search", "bpmag_show_search_results", 1); //highest priority
/* we just need to filter the query and change search_term=The search text */
function bpmag_show_search_results() {
//filter the ajaxquerystring
add_filter("bp_ajax_querystring", "bpmag_global_search_qs", 100, 2);
}
//show the search results for member*/
function bpmag_show_member_search() {
/*if (!bp_has_members( bp_ajax_querystring( 'members' ) ) ) : return; endif;*/
?>
<h2><?php _e("Member results", "bpmag"); ?></h2>
<div id="members-dir-list" class="members dir-list">
<?php locate_template(array('members/members-loop.php'), true); ?>
<?php global $members_template; ?>
<?php if ($members_template->total_member_count > 18): ?>
<a href="<?php echo bp_get_root_domain() . '/' . BP_MEMBERS_SLUG . '/?s=' . $_REQUEST['s'] ?>" ><?php _e(sprintf("View all %d matched members", $members_template->total_member_count), "bpmag"); ?></a>
<?php endif; ?>
</div><!-- #members-dir-list -->
<div class="clear"></div>
<hr/>
<?php
}
//Hook Member results to search page
add_action("advance-search", "bpmag_show_member_search", 30); //the priority defines where in page this result will show up(the order of member search in other searchs)
function bpmag_show_groups_search() {
/*if (!bp_has_groups( bp_ajax_querystring( 'groups' ) ) ) : return; endif; */
?>
<h2><?php _e("Group results", "bpmag"); ?></h2>
<div id="groups-dir-list" class="groups dir-list">
<?php locate_template(array('groups/groups-loop.php'), true); ?>
<?php global $groups_template; ?>
<?php if ($groups_template->total_group_count > 18): ?>
<a href="<?php echo bp_get_root_domain() . '/' . BP_GROUPS_SLUG . '/?s=' . $_REQUEST['s'] ?>" ><?php _e(sprintf("View all %d matched groups", $groups_template->total_group_count > 18), "bpmag"); ?></a>
<?php endif; ?>
</div><!-- #groups-dir-list -->
<div class="clear"></div>
<hr/>
<?php
}
//Hook Groups results to search page
if (bp_is_active('groups'))
add_action("advance-search", "bpmag_show_groups_search", 20);
/**
*
* Show blog posts in search
*/
function bpmag_show_site_blog_search() {?>
<h2><?php _e("Blog results", "bpmag"); ?></h2>
<?php if (!have_posts()) : ?>
<div id="message" class="info">
<p><?php _e( "Sorry, no posts were found.", 'buddypress' ); ?></p>
</div>
<div class="clear"></div>
<hr/>
<?php return; endif; ?>
<?php
$args = $GLOBALS['wp_query']->query;
$cat_concerts = get_category_by_slug(CONCERTS_CATEGORY_SLUG);
$cat_musicnews = get_category_by_slug(MUSICNEWS_CATEGORY_SLUG);
if ($cat_concerts && $cat_musicnews) :
$args['cat'] = implode(',', array($cat_concerts->term_id, $cat_musicnews->term_id));
query_posts($args);
endif;
?>
<div class="blog-search-result search-result">
<?php locate_template(array('post-loop.php'), true); ?>
</div>
<div class="clear"></div>
<?php
if ($cat_concerts && $cat_musicnews) :
wp_reset_query();
endif;
}
//Hook Blog Post results to search page
add_action("advance-search", "bpmag_show_site_blog_search", 40);
//show forums search
function bpmag_show_forums_search() {
?>
<h2><?php _e("Forum results", "bpmag"); ?></h2>
<div class="forums-search-result search-result">
<?php locate_template(array('forums/forums-loop.php'), true); ?>
<a href="<?php echo bp_get_root_domain() . '/' . BP_FORUMS_SLUG . '/?s=' . $_REQUEST['s'] ?>" ><?php _e("View All matched forum posts", "bpmag"); ?></a>
</div>
<div class="clear"></div>
<hr/>
<?php
}
//Hook Forums results to search page
if (bp_is_active('forums') && bp_is_active('groups') && ( function_exists('bp_forums_is_installed_correctly') && !(int) bp_get_option('bp-disable-forum-directory') ) && bp_forums_is_installed_correctly())
add_action("advance-search", "bpmag_show_forums_search", 50);
//show blogs search result
function bpmag_show_blogs_search() {
?>
<h2><?php _e("Blog results", "bpmag"); ?></h2>
<div class="blogs-search-result search-result">
<?php locate_template(array('post-loop.php'), true); ?>
<a href="<?php echo bp_get_root_domain() . '/' . BP_BLOGS_SLUG . '/?s=' . $_REQUEST['s'] ?>" ><?php _e("View All matched Blogs", "bpmag"); ?></a>
</div>
<div class="clear"></div>
<hr/>
<?php
}
//Hook Blogs results to search page if blogs comonent is active
if (bp_is_active('blogs'))
add_action("advance-search", "bpmag_show_blogs_search", 10);
//modify the query string with the search term
function bpmag_global_search_qs() {
return "search_terms=" . $_REQUEST['s'];
}
function bpmag_is_advance_search() {
global $bp;
if ($bp->current_component == BP_SEARCH_SLUG)
return true;
return false;
}
//show forums search
function bpmag_show_dedications_search() {?>
<h2><?php _e("Dedication results", "bpmag"); ?></h2>
<?php if (!have_posts()) : ?>
<div id="message" class="info">
<p><?php _e( "Sorry, no posts were found.", 'buddypress' ); ?></p>
</div>
<div class="clear"></div>
<hr/>
<?php return; endif; ?>
<?php
$args = $GLOBALS['wp_query']->query;
$args['category_name'] = DEDICATION_CATEGORY_SLUG;
query_posts($args);
?>
<div class="blogs-search-result search-result">
<?php locate_template(array('post-loop-dedication.php'), true); ?>
</div>
<div class="clear"></div>
<hr/>
<?php
wp_reset_query();
}
//Hook Forums results to search page
if (bp_is_active(BP_DEDICATION_SLUG))
add_action("advance-search", "bpmag_show_dedications_search", 10);
?>

View File

@ -2,7 +2,7 @@
jQuery(document).ready(function(){
jQuery('.wp-pagenavi a').live('click', function(e){
jQuery('.home-page .wp-pagenavi a').live('click', function(e){
e.preventDefault();
link = jQuery(this).attr('href');
jQuery('#content').html('Loading...');

View File

@ -14,6 +14,7 @@
<?php do_action( 'bp_before_members_loop' ); ?>
<?php $query_string = bp_ajax_querystring( 'members' ); ?>
<?php $is_request = strpos($query_string, 'scope=request'); ?>
<?php if ( bp_has_members( $query_string ) ) : ?>
<div id="pag-top" class="pagination">

View File

@ -17,8 +17,19 @@
<?php } ?>
<?php $post_status = 'publish'; ?>
<?php query_posts("$query_string&caller_get_posts=1&orderby=$orderby&order=$order&gdsr_sort=$gdsr_sort&gdsr_order=$gdsr_order&paged=$paged&post_status=$post_status&posts_per_page=".$gp_settings['posts_per_page']); ?>
<?php
$args = $GLOBALS['wp_query']->query;
$args['caller_get_posts'] = 1;
$args['orderby'] = $orderby;
$args['order'] = $order;
$args['gdsr_sort'] = $gdsr_sort;
$args['gdsr_order'] = $gdsr_order;
$args['paged'] = $paged;
$args['post_status'] = $post_status;
$args['posts_per_page'] = $gp_settings['posts_per_page'];
?>
<?php query_posts($args); ?>
<div id="content" class="fullwidth<?php if($gp_settings['dropdown_filter'] == "0") { ?> shift-down<?php } ?>">

View File

@ -16,8 +16,20 @@
</h1>
<?php } ?>
<?php query_posts("$query_string&caller_get_posts=1&orderby=$orderby&order=$order&gdsr_sort=$gdsr_sort&gdsr_order=$gdsr_order&paged=$paged&posts_per_page=".$gp_settings['posts_per_page']); ?>
<?php $post_status = 'publish'; ?>
<?php
$args = $GLOBALS['wp_query']->query;
$args['caller_get_posts'] = 1;
$args['orderby'] = $orderby;
$args['order'] = $order;
$args['gdsr_sort'] = $gdsr_sort;
$args['gdsr_order'] = $gdsr_order;
$args['paged'] = $paged;
$args['post_status'] = $post_status;
$args['posts_per_page'] = $gp_settings['posts_per_page'];
?>
<?php query_posts($args); ?>
<div id="content <?php echo (is_search()) ? "fullwidth" : ""; ?>"<?php if($gp_settings['dropdown_filter'] == "0") { ?> class="shift-down"<?php } ?>>

View File

@ -0,0 +1,55 @@
<?php /* this search loop shows your blog posts in the unified search
you may modify it as you want, It is a copy from my theme
*/
?>
<?php do_action('bp_before_blog_search') ?>
<?php
global $wp_query;
$wp_query->is_search = true;
$search_term = $_REQUEST['search-terms'];
if (empty($search_term))
$search_term = $_REQUEST['s'];
$wp_query->query("s=" . $search_term);
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()):the_post();
global $post; ?>
<?php do_action('bp_before_blog_post') ?>
<div> <!-- Post goes here... -->
<div>
<h3><?php the_title(); ?></h3>
<div>
<?php the_excerpt(); ?>
</div>
<div> </div>
</div>
<div>
<span><?php the_time('F j, Y') ?> | <?php the_category(', ') ?> | <?php comments_popup_link(__('No Comments &#187;', 'bpmag'), __('1 Comment &#187;', 'bpmag'), __('% Comments &#187;', 'bpmag')); ?></span>
<div><a href="<?php the_permalink(); ?>"><?php _e("Read more...", "bpmag"); ?></a></div>
</div>
</div><!-- Post ends here... -->
<?php do_action('bp_after_blog_post') ?>
<?php endwhile; ?>
<?php if (!bpmag_is_advance_search()): ?>
<div>
<?php if (function_exists("wp_pagenavi")) wp_pagenavi();else { ?>
<div><?php next_posts_link(__('&larr; Previous Entries', 'bpmag')) ?></div>
<div><?php previous_posts_link(__('Next Entries &rarr;', 'bpmag')) ?></div>
<?php } ?>
</div>
<?php endif; ?>
<?php else : ?>
<div>
<div>
<?php echo sprintf(__("We are sorry, but we could not find anything for the search term '%s'", "bpmag"), $search_term); ?>
<?php locate_template(array('searchform.php'), true) ?>
</div>
</div>
<?php endif; ?>
<?php do_action('bp_after_blog_search') ?>

View File

@ -0,0 +1,13 @@
<?php get_header();?>
<div id="content">
<div class="padder">
<?php do_action("advance-search");//this is the only line you need?>
<!-- let the search put the content here -->
</div> <!-- end of padder... -->
<div class="clear"> </div>
</div><!-- Container ends here... -->
<?php locate_template( array( 'sidebar.php' ), true ) ?>
<?php get_footer();?>

View File

@ -1,5 +1,13 @@
<?php get_header(); ?>
<?php require('post-loop.php'); ?>
<?php /* require('post-loop.php'); */ ?>
<div id="content fullwidth">
<div class="padder">
<?php do_action("advance-search"); ?>
</div><!-- .padder -->
</div>
<?php get_footer(); ?>