Forums

[resolved] Conflict between Sideblog and Popularity Contest (2 posts)

  1. ModiVivendi
    Member
    Posted 2 years ago #

    There seems to be a conflict between the plugins "popularity contest" and "sideblog". I am using the latest versions (Sideblog 3.8 and Popularity Contest 1.2.1 on WP 2.2.1)

    The symptom is that the last of the popular listings is shown twice (see the bottom of http://www.circularcommunication.com to see what I mean).

    Having only installed and tweaked Sideblog last night and thinking it works really well was I sad to see this unwanted side effect.

    I was wondering if anyone would be so kind as to tell me if something can be done to avoid this as I after searching high and low have found no solution.

    Thanks in advance,

    Jan

  2. ModiVivendi
    Member
    Posted 2 years ago #

    What a marvelous place the Blogosphere is. In addition to posting here did I also send out a couple of emails to bloggers who seemed to use the same combination of plugins and what do you know this is one of the answers and after following the advice it turns out to be a solution as well.

    Having asked for permission from frenchy @ http://www.frenchysfracas.com this is the entire email containing said solution:

    Hi Jan,

    I did the worst thing: I edited the file.. ;o)

    First things first: I'm currently using Popularity Contest 1.2.1 and Sideblog Wordpress Plugin 3.6 (most recent version is 3.8).

    So, basically it's a slight adjustment of the select statement - using a DISTINCT fetches just one distinct row of data. The Sideblog plugin, the Popularity Contest plugin and whatever's changed since Wordpress 2.1 gets us the double rows of the same data.

    1. find the popularity-contest.php file in your plugins directory
    2. make a backup copy and put somewhere in a different folder than the plugins folder (or else it
    might show up in your plugins admin page)
    3. edit the popularity-contest.php file:

    '
    - function show_top_ranked

    function show_top_ranked($limit, $before, $after) {
    global $wpdb;
    $temp = $wpdb;
    $join = apply_filters('posts_join', '');
    $where = apply_filters('posts_where', '');
    $groupby = apply_filters('posts_groupby', '');
    if (!empty($groupby)) { $groupby = ' GROUP BY '.$groupby; }
    $posts = $wpdb->get_results("
    >>> SELECT DISTINCT ID, post_title
    FROM $wpdb->posts
    LEFT JOIN $wpdb->ak_popularity pop
    ON $wpdb->posts.ID = pop.post_id
    $join
    WHERE post_status = 'publish'
    AND post_date < NOW()
    $where
    $groupby
    ORDER BY pop.total DESC
    LIMIT ".intval($limit)
    );

    - function show_top_ranked_in_cat

    function show_top_ranked_in_cat($limit, $before, $after,
    $cat_ID = '') {
    if (empty($cat_ID) && is_category()) {
    global $cat;
    $cat_ID = $cat;
    }
    if (empty($cat_ID)) {
    return;
    }
    global $wpdb;
    $temp = $wpdb;

    $join = apply_filters('posts_join', '');
    $where = apply_filters('posts_where', '');
    $groupby = apply_filters('posts_groupby', '');
    if (!empty($groupby)) { $groupby = ' GROUP BY '.$groupby; }

    $posts = $wpdb->get_results("
    >>> SELECT DISTINCT ID, post_title
    FROM $wpdb->posts
    LEFT JOIN $wpdb->post2cat pc
    ON $wpdb->posts.ID = pc.post_id
    LEFT JOIN $wpdb->ak_popularity pop
    ON $wpdb->posts.ID = pop.post_id
    $join
    WHERE pc.category_id = '".intval($cat_ID)."'
    AND post_status = 'publish'
    AND post_date < NOW()
    $where
    $groupby
    ORDER BY pop.total DESC
    LIMIT ".intval($limit)

    - function show_top_ranked_in_cat

    function show_top_ranked_in_month($limit, $before, $after,
    $m = '') {
    if (empty($m) && is_archive()) {
    global $m;
    }
    if (empty($m)) {
    global $post;
    $m = get_the_time('Ym');
    }
    if (empty($m)) {
    return;
    }
    $year = substr($m, 0, 4);
    $month = substr($m, 4, 2);
    global $wpdb;
    $temp = $wpdb;

    $join = apply_filters('posts_join', '');
    $where = apply_filters('posts_where', '');
    $groupby = apply_filters('posts_groupby', '');
    if (!empty($groupby)) { $groupby = ' GROUP BY '.$groupby; }

    $posts = $wpdb->get_results("
    >>> SELECT DISTINCT ID, post_title
    FROM $wpdb->posts
    LEFT JOIN $wpdb->ak_popularity pop
    ON $wpdb->posts.ID = pop.post_id
    $join
    WHERE YEAR(post_date) = '$year'
    AND MONTH(post_date) = '$month'
    AND post_status = 'publish'
    AND post_date < NOW()
    $where
    $groupby
    ORDER BY pop.total DESC
    LIMIT ".intval($limit)

    '

    I'm attaching both plugins, I'm not sure if I changed anything in the Sideblog plugin file..

    Best of Luck!

    regards,
    frenchy!

Topic Closed

This topic has been closed to new replies.

About this Topic