The MU forums have moved to WordPress.org

Main content widgets (1 post)

  1. mrjcleaver
    Member
    Posted 17 years ago #

    Hi all,
    I've hacked the widgets.php code to allow the embedding of a widget into a posting. Basically it creates a [[widget name]] syntax that is replaced by the widget during render.

    Codewise, you then supply a table that looks something like this (the forum screws up the HTML tags):

    register_sidebar_widget(
    "Today's Posts", 'mrjc_widgetize_function','', 'ah_recent_posts_mu', 'All Posts', '100', 'name',

  2. ', '
  3. ', 'updated'
    );

    register_sidebar_widget(
    'List All Blogs', 'mrjc_widgetize_function', '', 'list_all_wpmu_blogs',
    'All Blogs', '100', 'name', '

  4. ', '
  5. ', 'updated'
    );

    register_sidebar_widget(
    'List All Posts', 'mrjc_widgetize_function', '', 'list_all_wpmu_posts',\
    'All Posts', 30, 100, '<i>', '</i>', '<LI>', '... ','show','show','show'

    );

    And in postings or sidebar you can then type: [[List All Posts]] or [[Today's Posts]] to invoke.

    It works by registering a widget 'mrjc_widgetize_function' that takes the name of the real function to invoke.

    Its about 30 lines added to widgets.php plus the php file above with your specific bindings.

    It also has the advantage that you can make multiple friendly names that call the same PHP routine with different parameters. e.g. calling ah_recent_posts_mu with a number of days parameter.

    Now, given that someone would eventually be interested in the code, how and where best to share my work? The more eyeballs the better: I'm motivated as someone may be interested in improving on functionality and implementation, and I want the code to be kept up to date with releases of widgets.php.

About this Topic

  • Started 17 years ago by mrjcleaver