Forums

in-series plugin: all_series() doesn't return all series names (3 posts)

  1. JerryPeek
    Member
    Posted 2 years ago #

    I'm running In-Series 2.0 under WP 2.04. I've defined three series: test series, Another Test, and Query Input. I'm using the all_series() function, which is only documented in the in-series.txt file (not on Skippy's In-Series post). The function is supposed to return the names of all series inside pairs of <li> tags. But it only returns the name of one series, Query Input.

    I'm running it like this in sidebar.php:

    <?php if(function_exists('all_series')) { all_series('<li><h1>Series</h1><ul>', '</ul></li>', 'id'); } ?>

    I'm no PHP hacker, but I tried some debugging by editing the get_all_series() function to count how many times it looped through the foreach ($result as $r) loop. It looped once, which makes me think that there's something wrong in the $wpdb->get_results call??

    Ideas? If you use all_series(), does it return all of the series for you? Thanks a lot...

  2. JerryPeek
    Member
    Posted 2 years ago #

    I fiddled with the get_all_series() function to fix the problem -- I hope. I'm no PHP hacker, so I'd be glad for someone to correct me. Here's a patch to in-series.php version 2.0:

    --- in-series.php 2006/12/11 20:52:18 1.1
    +++ in-series.php 2006/12/11 21:19:56
    @@ -3,7 +3,7 @@
    Plugin Name: In Series
    Plugin URI: http://www.skippy.net/
    Description: Provides navigation controls for next/previous within a connected series of posts
    -Version: 2.0
    +Version: 2.0+
    Author: Scott Merrill
    Author URI: http://www.skippy.net/
    @@ -94,13 +94,24 @@
    AND b.meta_key='series_order')
    GROUP BY a.post_id
    ORDER BY CAST(b.meta_value AS SIGNED)
    - ASC LIMIT 1;");
    + ASC LIMIT 10;");
    if ( (! $result) || ( count($result) == 0 ) ) {
    return FALSE;
    }
    foreach ($result as $r) {
    + /*
    + * Suppress duplicates (by Jerry Peek, 11 Dec 2006):
    + */
    + if ($all) {
    + foreach ($all as $id => $title) {
    + if (strcmp($r->meta_value, $title) == 0) {
    + continue 2;
    + }
    + }
    + }
    + // If we get here, no existing value matches, so this isn't a duplicate:
    $all[$r->post_id] = $r->meta_value;
    }

    The indentation above doesn't appear, and this system doesn't seem to allow <pre> tags, so you'll just have to follow the braces. (I guess a bunch of &nbsp; entities would do the job...)

    In case you haven't seen patches before, this one says:

    1. Change the plugin version number (on line 6) from 2.0 to 2.0+. (This is an unofficial change, so I added a +.)
    2. In the call to $wpdb->get_results (line 97), change the LIMIT of 1 to 10. This returns up to 10 results. (I think it should be much higher -- probably the total number of post_ids in the database -- but I'm thinking that there must be a better way. Suggestions, please.)
    3. Add code before line 104 that doesn't add a new member to $all unless that series_name doesn't exist yet in $all.

    This is a hack, so I'm hoping someone who knows PHP and WP coding can fix it and show me a better way. Thanks.

  3. Quandary
    Member
    Posted 2 years ago #

    all_series() was a horribly, horribly broken interface. It has been relegated to in-series-legacy.php, to be kept around until such time that I deem it is worthy of axing altogether.

    Please check out the latest version of the plugin (3.0.7 at the time of writing). It provides much saner series listing options, and version 3.1 will have a widget to integrate series listing into the sidebar without having to hack PHP.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags