[Plugin: One search(Wordpress MU 2.8.1)] Need help?

3 replies
Hi,

I have sucessflly installed one search Plugin on wpmu 2.8.1 but I am getting some strange results, I mean whenever I make a search it shows a single result..... twice in search results.

Plz help me...

REGARDS
#plugin #searchwordpress #wpmu
  • Profile picture of the author qualitycontent
    Here r the codes plz help me check any multiple search array... if any :


    */

    /*
    To do:
    - Add join clause for non-post searches (i.e. tag searches)
    - Add install action for initial view setup
    */

    add_action ('posts_request','ju_search_view');
    add_action ('wpmu_new_blog','ju_build_views');
    add_filter('the_permalink', 'ju_get_blog_permalink');


    /*
    Get permalink from correct blog
    */
    function ju_get_blog_permalink () {
    global $post;
    return get_blog_permalink( $post->blog_id, $post->ID );
    }



    /*
    Override search to use generated post view (wp_v_posts)
    instead of searching blog tables
    */
    function ju_search_view ($request) {
    if(is_search()) {
    $v_query = preg_replace('/wp_(\d+)_/','wp_v_',$request);
    return $v_query;
    }
    return $request;
    }



    /*
    Builds a view that contains posts from all blogs.
    This function will only run when a new blog is created, deleted, archived, or suspended.
    */
    function ju_build_views ($blog_id) {
    global $wp_query;
    global $wpdb;

    $query = "SELECT blog_id, site_id, domain, path
    FROM wp_blogs
    WHERE
    archived = '0'
    AND mature = 0
    AND spam = 0
    AND deleted = 0";

    $blogs = $wpdb->get_results($query);

    $i = 0;
    $v_query = '';

    foreach ($blogs as $blog) {
    if ($i != 0) {
    $v_post_select_query .= ' UNION ';
    $v_postmeta_select_query .= ' UNION ';
    $v_comments_select_query .= ' UNION ';
    }
    $v_post_select_query .= " (SELECT '{$blog->blog_id}' AS blog_id, '{$blog->site_id}' AS site_id, '{$blog->domain}' AS domain, '{$blog->path}' AS path, wp_{$blog->blog_id}_posts.* FROM wp_{$blog->blog_id}_posts) ";
    $v_postmeta_select_query .= " (SELECT '{$blog->blog_id}' AS blog_id, '{$blog->site_id}' AS site_id, '{$blog->domain}' AS domain, '{$blog->path}' AS path, wp_{$blog->blog_id}_postmeta.* FROM wp_{$blog->blog_id}_postmeta) ";
    $v_comments_select_query .= " (SELECT '{$blog->blog_id}' AS blog_id, '{$blog->site_id}' AS site_id, '{$blog->domain}' AS domain, '{$blog->path}' AS path, wp_{$blog->blog_id}_comments.* FROM wp_{$blog->blog_id}_comments) ";
    $i++;
    }

    $v_query = 'CREATE OR REPLACE VIEW `wp_v_posts` AS ';
    $v_query .= $v_post_select_query;
    $wpdb->query($v_query);

    $v_query = 'CREATE OR REPLACE VIEW `wp_v_postmeta` AS ';
    $v_query .= $v_postmeta_select_query;
    $wpdb->query($v_query);

    $v_query = 'CREATE OR REPLACE VIEW `wp_v_comments` AS ';
    $v_query .= $v_comments_select_query;
    $wpdb->query($v_query);
    }

    ?>

    Regards
    {{ DiscussionBoard.errors[1018750].message }}
  • Profile picture of the author qualitycontent
    The search seems to work, but in the results list every post is listed twice. For each couple of identical results, one lists "No comments" while the other lists "Comments off" (which is not true).

    Any idea why this is happening?

    Regards
    {{ DiscussionBoard.errors[1020229].message }}
  • Profile picture of the author qualitycontent
    Thanx Matter resolved...

    it's due to..... sitewide tags plugin......which is already installed ... it;s picking up those posts too.
    {{ DiscussionBoard.errors[1023034].message }}

Trending Topics