Controlling Sidebars in Thematic

I started using Thematic a couple of weeks ago and have absolutely fallen in love it with. Mucho hooks and filters, which is key to customizing just like WordPress.

I needed a way to control the primary and secondary sidebar and which pages they would show up on without a plugin [Widget Logic] . After digging through the Thematic code and finding this awesome breakdown of Thematic. I discovered that I could shove some logic code in the Thematic hook ‘thematic_abovemainasides’. In fact you can shove the code in other Thematic hooks to control any Thematic widgetized area.

The code below shows the secondary sidebar only on the blog page and single pages, all other pages show the primary sidebar.

  • http://www.badcat.com/ Kel

    Will this work with the Crown Header in the “Thematic Power Blog”?

    • http://johndturner.com John Turner

      In theory yes, I don’t have the Thematic power Blog, so I’m not sure where all the hooks are at in.

  • http://www.whatsthebigidea.com whatsthebigidea.com

    John, Thanks for a nice clean fix which I’ve been looking for. Though I changed it slightly “if(is_page() || is_single())” however my home.php page which I want both asides to appear is missing the secondary as if it was a page? In other words the page and single pages to be controlled by your logic and the rest ignored. Thanks for any help!

  • http://www.whatsthebigidea.com whatsthebigidea.com

    I got it:

    // Sidebar Logic
    function childtheme_sidebar_logic() {
    function childtheme_sidebar_logic_filter($sidebars_widgets){
    if(is_page() || is_single()) {
    unset($sidebars_widgets['secondary-aside']);
    } else {
    unset($sidebars_widgets['']);
    }
    return $sidebars_widgets;
    }
    add_filter(‘sidebars_widgets’,'childtheme_sidebar_logic_filter’ );
    }
    add_action(‘thematic_abovemainasides’,'childtheme_sidebar_logic’)
    ?>

    Thanks again.