ThemeShaper Forums » Thematic

[closed]

Problems adding extra widget areas

(25 posts)
  • Started 14 years ago by jamesgreenhouse
  • Latest reply from Chris
  • This topic is not resolved
  1. jamesgreenhouse
    Member

    I am trying to add extra widget areas to the Thematic theme and have SORT OF managed to do it...
    I have added one to the right hand side of the header, and an extra Aside (_belowmainasides) in the sidebar.

    The problem is the extra Aside in the sidebar is being pushed to the bottom, level with the bottom of the main content area, leaving a big empty space between the bottom of the second aside and this new 3rd one.

    Have a look at http://jamestowers.com to see what i mean - under the "newsletter" section(there's a screenshot of the problem here for those who see this after the problem has been resolved http://jamestowers.com/thematicproblem.html).

    i have a feeling it has something to do with the child function.php below but i'm fairly new to php so obviously not too sure...

    Any ideas?

    <?php

    // This will create your header Aside widget area
    function my_widgets_head() {
    register_sidebar(array(
    'name' => 'Header Aside',
    'id' => 'header-aside',
    'before_widget' => '<li id="%1$s" class="widgetcontainer %2$s">',
    'after_widget' => "",
    'before_title' => "<h3 class=\"widgettitle\">",
    'after_title' => "</h3>\n",
    ));

    }
    add_action( 'init', 'my_widgets_head' );

    ////////////////////////////////////////

    // This will create tertiary Aside widget area
    function my_widgets_init() {
    register_sidebar(array(
    'name' => 'Tertiary Aside',
    'id' => 'tertiary Aside',
    'before_widget' => '<li id="%1$s" class="widgetcontainer %2$s">',
    'after_widget' => "\n",
    'before_title' => "<h3 class=\"widgettitle\">",
    'after_title' => "</h3>\n",
    ));

    }
    add_action( 'init', 'my_widgets_init');

    ////////////////////////////////////

    // adding the Header Aside widget area to your child theme
    function my_header_widgets() {
    if ( function_exists('dynamic_sidebar') && is_sidebar_active('header-aside') ) {
    echo '<div id="header-aside" class="aside">'. "\n" . '<ul class="xoxo">' . "\n";
    dynamic_sidebar('header-aside');
    echo '' . "\n" . '</div><!-- #header-aside .aside -->'. "\n";
    }
    }
    add_action('thematic_header', 'my_header_widgets', 4);

    /////////////////////////////////////////

    // adding the Tertiary Aside widget area to your child theme
    function my_sidebar_widgets() {
    if ( function_exists('dynamic_sidebar') && is_sidebar_active('tertiary Aside') ) {
    echo '<div id="tertiary" class="aside">'. "\n" . '<ul class="xoxo">' . "\n";
    dynamic_sidebar('tertiary Aside');
    echo '' . "\n" . ''. "\n";
    echo '' . "\n" . '</div><!-- #tertiary .aside -->'. "\n";
    }
    }
    add_action('thematic_belowmainasides', 'my_sidebar_widgets', 0);

    ?>

    Posted 14 years ago #
  2. in function my_sidebar_widgets() try adding a class of main-aside to #tertiary

    Posted 14 years ago #
  3. jamesgreenhouse
    Member

    Superb. I added the class "aside main-aside" which matched the other 2 above and everything looks as it should. Thanks.

    Posted 14 years ago #
  4. I have moved the subsidiary widgets above my footer and I have added a widget below the header called hero-aside.

    Is there anyway I can move these widgets into the main selector DIV as my design requires tiling a drop shadow background down the page?

    Not sure how to filter this into the main content area
    -----------------------------------------------------

    // This will create your new hero widget area
    function my_widgets_init() {
    register_sidebar(array(
    'name' => 'Hero Aside',
    'id' => 'hero-aside',
    'before_widget' => '<li id="%1$s" class="widgetcontainer %2$s">',
    'after_widget' => "",
    'before_title' => "<h3 class=\"widgettitle\">",
    'after_title' => "</h3>\n",
    ));

    }
    add_action( 'init', 'my_widgets_init' );

    // adding the new widget area to your child theme
    function my_hero_widgets() {
    if ( function_exists('dynamic_sidebar') && is_sidebar_active('hero-aside') && is_front_page() ) {
    echo '<div id="hero-aside" class="aside">'. "\n" . '<ul class="xoxo">' . "\n";
    dynamic_sidebar('hero-aside');
    echo '' . "\n" . '</div><!-- #hero-aside .aside -->'. "\n";
    }
    }
    add_action('thematic_belowheader', 'my_hero_widgets', 7);

    -------------------------------------------------------------

    // Let's move the subsidiary widget area above the footer
    function move_subsidiaries($content) {
    $content['1st Subsidiary Aside']['action_hook'] = 'thematic_abovefooter';
    $content['2nd Subsidiary Aside']['action_hook'] = 'thematic_abovefooter';
    $content['3rd Subsidiary Aside']['action_hook'] = 'thematic_abovefooter';
    return $content;
    }
    add_filter('thematic_widgetized_areas', 'move_subsidiaries');

    // Now we need to unhook everything else that's related to the subsidiary widget area
    function remove_relatedfunctions() {
    remove_action('widget_area_subsidiaries', 'thematic_subsidiaryopen', 10);
    remove_action('widget_area_subsidiaries', 'add_before_first_sub',20);
    remove_action('widget_area_subsidiaries', 'add_between_firstsecond_sub',40);
    remove_action('widget_area_subsidiaries', 'add_between_secondthird_sub',60);
    remove_action('widget_area_subsidiaries', 'add_after_third_sub',80);
    remove_action('widget_area_subsidiaries', 'thematic_subsidiaryclose', 200);
    }
    add_action('init', 'remove_relatedfunctions');

    // And now we need to add these functions to thematic_abovefooter()
    add_action('thematic_abovefooter', 'thematic_subsidiaryopen', 10);
    add_action('thematic_abovefooter', 'add_before_first_sub',20);
    add_action('thematic_abovefooter', 'add_between_firstsecond_sub',40);
    add_action('thematic_abovefooter', 'add_between_secondthird_sub',60);
    add_action('thematic_abovefooter', 'add_after_third_sub',80);
    add_action('thematic_abovefooter', 'thematic_subsidiaryclose', 200);
    --------------------------------------------------------------------

    Layout can be viewed here:

    http://www.dylancoynedesign.com/images/

    Cheers

    Posted 14 years ago #
  5. For the subsidiary action_hooks try using thematic_belowmainasides and for the hero-aside try hooking into thematic_abovecontainer

    -Gene

    Posted 14 years ago #
  6. Thanks Gene tried out using those two hooks. Here is the url if it helps
    http://clients.iris-digital.com/blogs/orange/

    Hero Aside
    ------------------------------------------------
    This didn't display anything on the static home page where I wanted it to appear only. Could it be something to do with the priority?

    // adding the new widget area to your child theme
    function my_hero_widgets() {
    if ( function_exists('dynamic_sidebar') && is_sidebar_active('hero-aside') && is_front_page() ) {
    echo '<div id="hero-aside" class="aside">'. "\n" . '<ul class="xoxo">' . "\n";
    dynamic_sidebar('hero-aside');
    echo '' . "\n" . '</div><!-- #hero-aside .aside -->'. "\n";
    }
    }
    add_action('thematic_abovecontainer', 'my_hero_widgets', 7);

    Subsidiary Asides
    --------------------------------------------
    It works on my blog pages but not on my static front page. So I tried to put an if statement in there but I am not sure if I closed it off correctly as its now i am getting asides in footer as well as below main asides.

    // Let's move the subsidiary widget area below the main asides on front static page as well as subsequent pages
    function move_subsidiaries($content) {
    if ( function_exists('dynamic_sidebar') && is_front_page() ) {
    $content['1st Subsidiary Aside']['action_hook'] = 'thematic_belowmainasides';
    $content['2nd Subsidiary Aside']['action_hook'] = 'thematic_belowmainasides';
    $content['3rd Subsidiary Aside']['action_hook'] = 'thematic_belowmainasides';
    }
    return $content;

    }
    add_filter('thematic_widgetized_areas', 'move_subsidiaries');

    // Now we need to unhook everything else that's related to the subsidiary widget area
    function remove_relatedfunctions() {
    remove_action('widget_area_subsidiaries', 'thematic_subsidiaryopen', 10);
    remove_action('widget_area_subsidiaries', 'add_before_first_sub',20);
    remove_action('widget_area_subsidiaries', 'add_between_firstsecond_sub',40);
    remove_action('widget_area_subsidiaries', 'add_between_secondthird_sub',60);
    remove_action('widget_area_subsidiaries', 'add_after_third_sub',80);
    remove_action('widget_area_subsidiaries', 'thematic_subsidiaryclose', 200);
    }
    add_action('init', 'remove_relatedfunctions');

    // And now we need to add these functions to thematic_belowmainasides()
    add_action('thematic_belowmainasides', 'thematic_subsidiaryopen', 10);
    add_action('thematic_belowmainasides', 'add_before_first_sub',20);
    add_action('thematic_belowmainasides', 'add_between_firstsecond_sub',40);
    add_action('thematic_belowmainasides', 'add_between_secondthird_sub',60);
    add_action('thematic_belowmainasides', 'add_after_third_sub',80);
    add_action('thematic_belowmainasides', 'thematic_subsidiaryclose', 200);

    Cheers D

    Posted 14 years ago #
  7. Hi dylancoyne,

    I'll test this out later on today and see what I can figure out

    -Gene.

    Posted 14 years ago #
  8. Hi again,

    I managed to get the hero widget problem resolved. I had a look at Chris's code tips and soemthing clicked. I was using a specific main.php template for the static home page.

    I used Chris's remove sidebar function, changed the template to default and the thematic_abovecontainer hook then worked.

    // filter thematic_sidebar() .. no display for the page 'Home', keep it for the rest
    function remove_sidebar() {
    // We test if we are on the page 'Home'
    if (is_page()) {
    // Yes, we are .. now we switch off the sidebar
    return FALSE;
    } else {
    // we are not .. we leave the switch on
    return TRUE;
    }
    }
    // Connect the filter to thematic_sidebar()
    add_filter('thematic_sidebar', 'remove_sidebar');

    I then applied the same logic to the subsidiary asides using the thematic_belowcontainer and this worked also. All my widgets are now within the main div.

    However, on the blog page the sidebar with primary and secondary asides now appear below the subsidiary asides.

    Cheers D

    Posted 14 years ago #
  9. Admittedly I'm not quite following your progression here.

    It sounds like you need adjust the conditional for changing the hook to account for !is_home() That is to say when you are not on your blog.

    Posted 14 years ago #
  10. Not making myself very clear probably.

    Hero widget resolved. My unresolved problem is when we move the subsidiary asides below main asides. It works on the blog page fine but when it's not the home page, as you recommended !is_home(), it doesn't seem to work.

    I am not sure if I am putting the if statemnet in the right place.

    // Let's move the subsidiary widget area below the main asides on front static page as well as subsequent pages
    function move_subsidiaries($content) {

    if (!is_home()) {
    $content['1st Subsidiary Aside']['action_hook'] = 'thematic_belowmainasides';
    $content['2nd Subsidiary Aside']['action_hook'] = 'thematic_belowmainasides';
    $content['3rd Subsidiary Aside']['action_hook'] = 'thematic_belowmainasides';
    }
    return $content;

    }
    add_filter('thematic_widgetized_areas', 'move_subsidiaries');

    // Now we need to unhook everything else that's related to the subsidiary widget area
    function remove_relatedfunctions() {

    remove_action('widget_area_subsidiaries', 'thematic_subsidiaryopen', 10);
    remove_action('widget_area_subsidiaries', 'add_before_first_sub',20);
    remove_action('widget_area_subsidiaries', 'add_between_firstsecond_sub',40);
    remove_action('widget_area_subsidiaries', 'add_between_secondthird_sub',60);
    remove_action('widget_area_subsidiaries', 'add_after_third_sub',80);
    remove_action('widget_area_subsidiaries', 'thematic_subsidiaryclose', 200);

    }
    add_action('init', 'remove_relatedfunctions');

    // And now we need to add these functions to thematic_belowmainasides()
    add_action('thematic_belowmainasides', 'thematic_subsidiaryopen', 10);
    add_action('thematic_belowmainasides', 'add_before_first_sub',20);
    add_action('thematic_belowmainasides', 'add_between_firstsecond_sub',40);
    add_action('thematic_belowmainasides', 'add_between_secondthird_sub',60);
    add_action('thematic_belowmainasides', 'add_after_third_sub',80);
    add_action('thematic_belowmainasides', 'thematic_subsidiaryclose', 200);

    Posted 14 years ago #
  11. Crap :/ Lemme check on something.

    Posted 14 years ago #
  12. Thanks Gene.

    This is a real head scratcher as I can't see how thematic_belowmainasides() can work with thematic_widgetized_areas when on a static page when the sidebar is inactive...

    Posted 14 years ago #
  13. I dont think a filter of thematic_widgetized_areas is ever going to find any conditional tag as true. I put word out to Chris that I'm stumped on this one.

    Posted 14 years ago #
  14. Working on it.

    Posted 14 years ago #
  15. Found a solution! But don't expect anything this evening. Think I need to rewrite several parts of my code :)

    Posted 14 years ago #
  16. Thanks Chris. I appreciate your efforts and hope it is useful for others.

    It's good fun playing around with widgetised areas, controlling a theme with a couple of files, functions and stylesheets.

    D ;)

    Posted 14 years ago #
  17. Hi Dylan,

    please get the latest copy from the SVN. This will work as expected :)

    Chris

    Posted 14 years ago #
  18. Hi Chris,

    I had a break from this over the weekend.

    I followed the thread on the forum to download the latest SVN version of thematic. I copied this to my terminal on a MAC:

    svn checkout http://thematic.googlecode.com/svn/trunk/ thematic-read-only

    Uploaded the core files of thematic. It works for the blog page only as before but when I add the conditional statement it breaks.

    function move_subsidiaries($content) {

    if (!is_home()) {
    $content['1st Subsidiary Aside']['action_hook'] = 'thematic_belowmainasides';
    $content['2nd Subsidiary Aside']['action_hook'] = 'thematic_belowmainasides';
    $content['3rd Subsidiary Aside']['action_hook'] = 'thematic_belowmainasides';
    }
    return $content;

    }
    add_filter('thematic_widgetized_areas', 'move_subsidiaries');

    I wonder if got the latest copy from SVN or my if statement is incorrect?

    Thanks

    Posted 14 years ago #
  19. Hi dylancoyne

    If you used that terminal command svn checkout http://thematic.googlecode.com/svn/trunk/ then you got the latest copy.

    I have tested the code from your last post and It works as it is intended to for me with trunk rev 644 . There must be something else going on that we aren't seeing. Have you checked your error logs or tried setting error display on in your wp-config? Maybe that'll help.

    @Chris - I havent tested this beyond this case but it appears to work great here. I suspected widgets_init was impeding the conditional but I wasn't quite seeing how to integrate template_redirect Good work, thanks again.

    -Gene

    Posted 14 years ago #
  20. @Gene - Thanks! :)

    @Dylan - Could you please give us some more details? What is breaking?

    Chris

    Posted 14 years ago #
  21. Hi Chris/Gene,

    I will try again tomorrow. It's been a long day. If it still doesn't work for me would it help if I emailed my functions.php file?

    Cheers

    dylan

    Posted 14 years ago #
  22. Hi Dylan,

    look into the /thematic/library/extensions/widgets-extensions.php

    line 32 should be function thematic_widgets_array(). If not, then reload the SVN copy.
    If yes .. email your functions.php to chris (at) thematic4you (dot) com

    Chris

    Posted 14 years ago #
  23. Hi Chris,

    I emailed you yesterday with my functions.php

    Cheers

    Dylan

    Posted 14 years ago #
  24. .. will send the solution as soon as I'm back at home.

    Chris

    Posted 14 years ago #
  25. .. working copy is on it's way.

    Dylan, drop a note if it's working on your machine and publish the working code here.

    Thanks,

    Chris

    Posted 14 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.