The MU forums have moved to WordPress.org

How do you add the WPMU "List All..." widgets found in the Codex? (4 posts)

  1. DanYork
    Member
    Posted 14 years ago #

    I have WPMU 1.3 installed and everything seems to be working fine. On the main "portal" page (when you go to the main site), I would like to add a list of all the blogs on the site as well as a list of recent posts from across all blogs.

    In the WordPress Codex there are the following widgets listed that would seem to provide what I am seeking:

    http://codex.wordpress.org/WPMU_List_All_Blogs_Widget
    http://codex.wordpress.org/WPMU_List_All_Postings_Widget
    http://codex.wordpress.org/WPMU_List_New_Blogs_Widget (listed as untested)

    However, I can't seem to get this code to work.

    - I have tried created a widgets.php file in my mu-plugins directory. That gave me an error that register_sidebar_widget was not a known function.

    - I tried putting a similar file in plugins and that didn't work either.

    - I tried editing the widgets.php file in the wp-admin directory and this, too, did not work.

    In further searching around (grep is your friend), I can't find a 'register_sidebar_widget' function but there is a 'wp_register_sidebar_widget' function that looks like it takes different parameters (and I did try modifying the widget code but that didn't work). The widget code snippets also seem to call functions that don't appear in the code base such as 'list_all_wpmu_posts'... at least, I couldn't find such a function in the code when I searched it.

    So at this point I am led to conclude that either:

    1. There is some place else I need to put this.
    2. These code snippets rely on some other plugin or add-on that I don't have installed with WPMU 1.3.
    3. These code snippets are for an older version of WPMU, perhaps one that relied on the widgets plugin when it was needed and won't work with WPMU 1.3.

    In my ideal world, I would like these functions not as sidebar widgets but as something that I could put on the main home page. However, I'd also like the "List All Blogs" as a widget that I can put onto each of the sidebars of the blogs in the site (there will only be 5-20 blogs). Right now I'll take whatever I can get!

    Any help or suggestions would be greatly appreciated.

    Thanks,
    Dan

  2. andrea_r
    Moderator
    Posted 14 years ago #

    You are making this far, far too complicated.

    Those chunks of code? make an empty file in your mu-plugins folder. Call it list_all_posts. Copy the code from that codex page and paste it in that file you just made. Save it.

    That's it. It now will magically appear in your widgets list.

    Now that I read the code involved they DO rely on a couple of exisiting plugins:
    http://wpmudevorg.wordpress.com/project/List-All-Posts
    http://wpmudevorg.wordpress.com/project/List-All

    Which, really - you can use thsoe plugins I just linked without bothering with the code liste din the codex - that's just to make those elements widgetized.

    Whoever did those stubs needs to go back and add some clear directions, and not just plunk in random code snippets.

  3. DanYork
    Member
    Posted 14 years ago #

    andrea_r - I *love* it when someone is telling me that I'm making something far too complicated! That's the problem when you turn a former developer loose on a code base he doesn't yet understand!

    Thanks for the pointer to those two plugins. I've now installed them and they do pretty much exactly what I want. (Well, I'd like an alpha-sorted list of blogs, but I've raised that question on the blog of the developer, and I won't complain given how much I paid for the plugin!)

    For a variety of reasons, I *would* like to have them widgetized for a theme I'm building, but unfortunately the code *as written* in the Codex dies in WPMU 1.3:
    ----
    Fatal error: Call to undefined function: register_sidebar_widget() in /var/www/html/wpmu/wp-content/mu-plugins/list_all_widgets.php on line 13
    ----
    This seems odd given that other code for widgets does seem to call this same function.

    Anyway, thanks for the help with the pointers to the plugins.

  4. iolaire
    Member
    Posted 14 years ago #

    Dan, I've been having the same problem, your post made me look at it again, here is the fix:

    /*
    Plugin Name: List-All-Blogs Widget
    Plugin URI: http://codex.wordpress.org/WPMU_List_All_Blogs_Widget
    Description: Creates a list of all blogs on a WPMU site as a widget, conversion from previous version based on code in http://www.erik-rasmussen.com/blog/2006/11/30/widgetize-anything/
    Author: Unkown - last edited Iolaire McFadden
    Author URI: http://codex.wordpress.org/WPMU_List_All_Blogs_Widget
    Version: 0.0.1
    */
    
    function widget_list_all_blogs_init() {
    	if ( !function_exists('register_sidebar_widget') )
    		return;
    
    	function widget_list_all_blogs($args) {
            extract($args);
    
            if(function_exists(list_all_wpmu_blogs)) {
                     echo $before_widget;
    
                     echo $before_title . 'All Blogs' . $after_title;
                            echo "<ul>\n";
                            list_all_wpmu_blogs('100', 'name', '<li>', '</li>', 'updated');
                            echo "</ul>\n";
                     echo $after_widget;
            }
    		else
    		{
                     echo "Error - function  list_all_wpmu_blogs not found";
            }
    	}
    
        if ( function_exists('wp_register_sidebar_widget') ) // fix for wordpress 2.2.1
          wp_register_sidebar_widget(sanitize_title('Widgetize list all blogs' ), 'Widgetize list all blogs', 'widget_list_all_blogs', array(), 1);
        else
          register_sidebar_widget('Widgetize list all blogs', 'widget_list_all_blogs', 1);
    }
    add_action('plugins_loaded', 'widget_list_all_blogs_init');
    ?>

About this Topic