ThemeShaper Forums » Thematic

[closed]

creating multiple new widget areas with an array?

(3 posts)
  • Started 9 years ago by guswhite
  • Latest reply from guswhite
  • This topic is resolved
  1. guswhite
    Member

    Firstly just like to say this is a great forum, I have only just started working with Thematic and all the info on here has been great. I am new to PHP but have managed to successfully accomplish everything so far with a bit of copy and pasting and my small amount of common sense!

    My question is this:
    How do I create multiple widget areas for use in a childtheme_secondary_aside that I created using Chris' code from http://forums.themeshaper.com/topic/something-new-bout-widgetized-areas#post-6660

    The different widget areas are then displayed conditionally (this I have managed to acheive)

    Currently my code looks like this:

    function change_secondary_aside($content) {
    $content['Secondary Aside']['function'] = 'childtheme_secondary_aside';
    $content['Third Aside Pages'] = array(
    'admin_menu_order' => 201,
    'args' => array (
    'name' => 'Third Aside Pages',
    'id' => 'third-aside-pages',
    'before_widget' => thematic_before_widget(),
    'after_widget' => thematic_after_widget(),
    'before_title' => thematic_before_title(),
    'after_title' => thematic_after_title(),
    ),
    'action_hook' => 'thematic_secondary_aside',
    'function' => 'childtheme_secondary_aside',
    'priority' => 10,
    );

    return $content;
    }
    add_filter('thematic_widgetized_areas','change_secondary_aside');

    function childtheme_secondary_aside() {
    if (is_sidebar_active('secondary-aside') && is_sidebar_active('third-aside-pages')) {
    echo thematic_before_widget_area('secondary-aside');
    if ( is_tree('90')) {
    dynamic_sidebar('third-aside-pages');
    } elseif (is_tree('100')) {
    dynamic_sidebar('fourth-aside-pages');
    } else {
    dynamic_sidebar('secondary-aside');
    }
    echo thematic_after_widget_area('secondary-aside');
    }
    }

    and then I have this other function to create the fourth-aside-pages widget

    function add_fourth_aside($content) {
    $content['Fourth Aside Pages'] = array(
    'admin_menu_order' => 202,
    'args' => array (
    'name' => 'Fourth Aside Pages',
    'id' => 'fourth-aside-pages',
    'before_widget' => thematic_before_widget(),
    'after_widget' => thematic_after_widget(),
    'before_title' => thematic_before_title(),
    'after_title' => thematic_after_title(),
    ),
    'action_hook' => 'thematic_secondary_aside',
    'function' => 'childtheme_secondary_aside',
    'priority' => 8,
    );
    return $content;
    }
    add_filter('thematic_widgetized_areas', 'add_fourth_aside');

    This works but seems ugly and I would imagine that there is a way that I can get change_secondary_aside function to create more than one widget? My guess would be by using an array but I have no idea how the syntax should look. I tried a couple of things having looked at the widgets-extensions.php file but due to my lack of PHP knowledge they didn't work.

    Anyone got any advice.

    Thanks!

    Posted 9 years ago #
  2. Hi guswhite,

    Or you can take the cheaty way like I did and use the plugin Widget Context :)

    Posted 9 years ago #
  3. guswhite
    Member

    Perfect that does the trick! Thanks

    Posted 9 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.