ThemeShaper Forums » Thematic

[sticky] [closed]

Something new 'bout widgetized areas

(70 posts)
  • Started 4 years ago by Chris
  • Latest reply from candregg
  • This topic is not a support question
  1. RahulB
    Member

    Hi Chris,

    I thought the version of thematic on themeshaper.com/thematic would be the latest(0.9.5.1).
    Only when you mentioned 0.9.6 that I realised the a newer version can be obtained from http://code.google.com/p/thematic/

    Hope this helps other who thought like me.

    -Rahul

    Posted 4 years ago #
  2. markd
    Member

    This is beautiful. It looks just like the thing I need. But the examples on the previous page all differ somewhat from what I want to do. Here what I need:

    I want to give a number of pages their own sidebars instead of 'Primary Aside'. So I want widgetized areas called 'Frontpage', 'About', and 'Contact us', which should be displayed conditionally — 'Frontpage' when on the frontpage and so on. And (here's the catch), I also want these sidebars to show up on child pages of the relevant pages. That is, a child page of 'About' should also display the 'About' widgetized area. On all specified pages (and their children), the special sidebar comes in place of 'Primary Aside'. In other words, the primary aside is the default for pages which do not have their own sidebar.

    It looks like the code for adding a widgetized area here is what I need, but I have two questions: (1) How to I create six of these widgetized page-bound areas in one go (instead of having six separate functions), and (2) what 'action hook' do I need to hook it to?

    Posted 4 years ago #
  3. Just wondered if the code for adding a new widget has changed significantly since Chris' last posts?

    Posted 4 years ago #
  4. markd
    Member

    No, it doesn't look like it changed much. That is, I succeeded in adding a new widgetized area.

    I'm just looking for the most elegant way to (1) define 5-10 new widget areas which are named after (parent) pages, and (2) show these areas instead of 'Primary Aside' on the relevant parent pages and their children.

    Previously I would've done this just by registering sidebars manually and calling them via a conditional in page.php or sidebar.php, but the way I understand Thematic this would not be the most elegant or expedient way.

    Posted 4 years ago #
  5. markd
    Member

    Is the sorting using admin_menu_order already supposed to work?

    Posted 4 years ago #
  6. ooh me me
    Member

    Hey Chris or anyone,

    Regarding 'removing widgetized area'... is it more beneficial to create a function to remove the area (ie. primary) vs. creating a new page template and deleting the call to thematic_sidebar? Or using "Widget-logic" and dynamic-class styling?

    My nubish self assumes many of the sidebar customizing issues people ask about can be solved by creating semantic templates (ie category-x.php to remove sidebars for pages/posts with that id-X)...but is it cleaner, or faster to use functions?

    I'm just trying to grasp best-practices...Thanks

    Posted 4 years ago #
  7. I had a question about the "header aside" widget you created? i added the first 2 blocks of code to my functions.php. and i added the css to my style.css (in my thematic power blog theme). my thinking was that the "header aside" should then show up with the other widgets in the control panel in word press? but I don't see it? am I missing something simple here? thank you so much!!!

    website with the code added is here: www.hawaiicoupondiva.com

    Posted 4 years ago #
  8. Hi all,

    @markd - Yes sorting by admin menu order will work in 0.9.6.1. Are you still having difficulty with this?

    @ooh me me - imho it's be best to deal with this in the child's functions.php but for some it may be simpler to create templates. Down the road maintaining the function will likely be easier than maintaining the templates should the Thematic core get modified.

    @ kemilie - what version of thematic do you have installed. Thematic 0.9.6.1 or later is needed for the mods in this thread

    -Gene

    Posted 4 years ago #
  9. BAC
    Member

    Has anyone had any issues with implementing the header aside widget and the superfish dropdowns - it bourks them for me.

    Can't see anything obvious, so has anyone noticed this problem also?

    I am on 0.9.6.1

    Cheers

    BAC

    Posted 4 years ago #
  10. ooh me me
    Member

    @Gene...aw yes that makes sense. It's all about easing and simplifying future modifications. Thanks.

    Posted 4 years ago #
  11. Gene - good suggestion. I upgraded to the newest but am still just not seeing anything in the widgets area?

    Posted 4 years ago #
  12. kemilie-

    Given that this post has grown long enough for me to get a bit confused. Go ahead and post the code you added to your functions.php for the header aside bit and maybe that'll shed a little light on the matter.

    -Gene

    Posted 4 years ago #
  13. Hmmm... asking for help gave me the magical insight to suddenly fix it. Thank you! :-)

    Posted 4 years ago #
  14. markd
    Member

    Good, I got the sorting to work on 0.9.6.1.

    Posted 4 years ago #
  15. Chris / Ian - I want to make this a sticky topic. Can I?

    I know I technically can ... but should I? I find my self coming back to this page again and again and every time it takes me ages to find it (Will try and find the time to add this into the Guide ... I think there is an article about this also???)

    Posted 3 years ago #
  16. @sareiodata +1 This should be added to the guide. This thread is bookmarked for me as well.

    Also, wondering if I could get some support with the conditional loading of widget areas. The following code seems to work for everything except for the is_page_template('template.php') && is_page('page-name') calls.

    Anyone have a suggestion?

    // Change Secondary Output to Display Widget Areas Conditionally
    
    function childtheme_secondary_aside() {
    	if (is_sidebar_active('secondary-aside') && is_sidebar_active('blog-sidebar')) {
    		echo thematic_before_widget_area('secondary-aside');
    		if (is_page()) {
    			dynamic_sidebar('secondary-aside');
    		}  elseif (is_page_template('template-helpcenter.php') || is_page('help-center') || is_category('help-center') || in_category('help-center')) {
    		  	dynamic_sidebar('helpcenter-sidebar');
    		}  elseif (is_page_template('template-blog.php')) {
    		  	dynamic_sidebar('blog-sidebar');
    		} else {
    			dynamic_sidebar('blog-sidebar');
    		}
    		echo thematic_after_widget_area('secondary-aside');
    	}
    }
    Posted 3 years ago #
  17. Hi Devin,

    The problem with the code you've posted is with the logical order of the conditional cascade.
    elseif (is_page_template('template-helpcenter.php') will never been true because the preceding
    if (is_page()) ends the conditional statement.

    Move the is_page closer to the end... behind the other template specific and page specific conditions and this will work as you intended.

    -Gene

    Posted 3 years ago #
  18. I was hoping it was something simple like that. Thanks for the heads up Gene.

    Additionally, because my page template had the following in it:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("paged=$paged"); ?>

    I don't think it was properly recognizing what it needed to do in the sidebar.

    I added wp_reset_query(); to my page template after the query loop was done, and that fixed the other problem.

    Posted 3 years ago #
  19. Oh, I would love to have a header aside!

    I have added the code to the bottom functions.php and header.php in my child theme but I don't see a new header-aside widget in the widgets admin area. Isn't that the intended result?

    I'm going to try to put the code here (I'm no coder, so I'll just paste the whole thing if I may...):

    Here is my whole functions.php -- the header-aside widget is after the logo-image function added too.

    <?php
    // comments left out
    ?>
    <?php
    // ---------- Adding the logo image to the header STARTS HERE
    
    if(get_option('child_theme_logo_enabled')){
    	function remove_thematic_blogtitle() {
    	 remove_action('thematic_header','thematic_blogtitle',3);
    	}
    	add_action('init','remove_thematic_blogtitle');
    
    	function remove_thematic_blogdescription() {
    	 remove_action('thematic_header','thematic_blogdescription',5);
    	}
    	add_action('init','remove_thematic_blogdescription');
    
    	function thematic_logo_image() {
    		echo '<div id="logo-image"><a href="'.get_option('home').'"><img src="'.get_option('child_theme_image').'" /></a></div>';
    	}
    	add_action('thematic_header','thematic_logo_image',4);
    }
    // ---------- Adding the logo image to the header ENDS HERE
    // ----------------- Custom header aside starts here
    function add_header_aside($content) {
    	$content['Header Aside'] = array(
    		'args' => array (
    			'name' => 'Header Aside',
    			'id' => 'header-aside',
    			'before_widget' => thematic_before_widget(),
    			'after_widget' => thematic_after_widget(),
    			'before_title' => thematic_before_title(),
    			'after_title' => thematic_after_title(),
    		),
    		'action_hook'	=> 'thematic_header',
    		'function'		=> 'thematic_header_aside',
    		'priority'		=> 8,
    	);
    	return $content;
    }
    add_filter('thematic_widgetized_areas', 'add_header_aside');
    
    // And this is our new function that displays the widgetized area
    function thematic_header_aside() {
    	if (is_sidebar_active('header-aside')) {
    		echo thematic_before_widget_area('header-aside');
    		dynamic_sidebar('header-aside');
    		echo thematic_after_widget_area('header-aside');
    	}
    } ?>

    Okay, now here is a snippet from header.php code:

    <?php thematic_aboveheader(); ?>   
    
        <div id="header">
            <?php thematic_header() ?>
        </div><!-- #header-->
    <?php
    // First we remove the thematic_brandingopen() .. we're going to make one addition for this one.
    // And we remove thematic_access() .. will be added later unchanged with a priority of 10.
    function remove_branding() {
    		remove_action('thematic_header','thematic_brandingopen',1);
    		remove_action('thematic_header','thematic_access',9);
    }
    add_action('init', 'remove_branding');
    
    // We wrap #branding and #header-aside with #header-box
    function childtheme_brandingopen() { ?>
    	<div id="header_box">
        	<div id="branding">
    <?php }
    add_action('thematic_header','childtheme_brandingopen',1);
    
    // Now we need to close #header-box
    function header_box_close() { ?>
    	</div>
    <?php }
    add_action('thematic_header', 'header_box_close', 9);
    
    // And we add the unchanged thematic_access() with the new priority 10
    add_action('thematic_header','thematic_access', 10);   ?>    
    
    <?php thematic_belowheader(); ?>
        <div id="main">

    I hope somebody can tell me what to do to get this mouthwatering header widget working....

    Posted 3 years ago #
  20. Oh, I found how to do it.

    The post is right here on themeshaper forums --

    http://forums.themeshaper.com/topic/widgets-in-the-header

    Thanks everyone. Great resources here.

    Posted 3 years ago #
  21. Hey everyone,

    Great theme and a great forum. I've learned a ton by just hanging out here.

    I'm trying to make the Primary sidebar appear only on blog pages and the Secondary sidebar appear only on pages.

    I am using the code that Chris posted above, but having some trouble after I tried to conditionally alter the Primary area. I keep getting the white screen of death and can't figure out where I'm going wrong.

    Any help would be greatly appreciated.

    Here's what I have:


    // Display Secondary Sidebar only on pages

    function childtheme_secondary_aside() {
    if (is_page()) {
    if (is_sidebar_active('secondary-aside')) {
    echo thematic_before_widget_area('secondary-aside');
    dynamic_sidebar('secondary-aside');
    echo thematic_after_widget_area('secondary-aside');
    }
    }
    }

    function change_secondary_aside($content) {
    $content['Secondary Aside']['function'] = 'childtheme_secondary_aside';
    return $content;
    }
    add_filter('thematic_widgetized_areas','change_secondary_aside');

    // Display Primary Sidebar only on blog pages

    function childtheme_primary_aside() {
    if (is_page() || is_home()) {
    if (is_sidebar_active('primary-aside')) {
    echo thematic_before_widget_area('primary-aside');
    dynamic_sidebar('primary-aside');
    echo thematic_after_widget_area('primary-aside');
    }
    }
    }

    function change_secondary_aside($content) {
    $content['Primary Aside']['function'] = 'childtheme_primary_aside';
    return $content;
    }
    add_filter('thematic_widgetized_areas','change_primary_aside');

    Posted 3 years ago #
  22. alexL
    Member

    Hi guys,

    Great forum and Wordpress theme! I'm a novice coder and working my way through the discussions on this forum to customise my thematic site.

    I've seen the code Chris posted on adding a widgetized area to the header. But I'd actually like to add a couple more beneath the Secondary aside in the sidebar.

    Is anyone able to post up the code for this?

    Many Thanks

    Alexei

    Posted 3 years ago #
  23. mithers
    Member

    I was browsing around the forum and got to this thread , its feels great when People are sharing information with eachother so that others can learn. Keep this going ever.

    Posted 3 years ago #
  24. rekopacz
    Member

    Hi Chris, first I am glad I stumbled on this, the short tutorial on creating the header aside, it was just what I was looking for! Have a related question. I am trying to create a theme for a client that will use Widget Context and Improved Include Page plugins, together with custom widget areas, to create a more WYSIWYG-friendly environment for the widget areas. First, If I want to create a widget region, but not insert it anywhere, I can just take out the 'action hook' instruction from that filter for the header aside, and then just call it anywhere I want to in the template with the get_sidebar function, correct? Also, I would like some widget regions to use divs instead of unordered lists. I assume I would need to create custom functions that correspond to thematic_before_widget, etc. and call them into the function that creates the new widget area. Is that correct?

    Thanks again for building that header aside function, it was like a breath of fresh air.

    Posted 3 years ago #
  25. maren.m
    Member

    Hi everybody on this wonderful forum-

    Did anyone ever address DK's problem above, from about 7 months ago?

    I am having the same problem with displaying sidebars conditionally (Primary on blog, Secondary on pages).

    My code is almost identical but I'm not sure what's wrong with it.

    Thanks!

    Posted 3 years ago #
  26. @maren- someone else just asked this the other day. i answered here. i didn't test it but it ought to put you on the right path.

    http://forums.themeshaper.com/topic/alternating-sidebars-depending-on-homepages

    Posted 3 years ago #
  27. maren.m
    Member

    Thanks so much for your help--I was the one who posted that other thread! I thought it got deleted somehow so I reposted.

    I still cannot get it to work! Several of the pages appear with no sidebar, one of the pages doesn't appear at all (the white screen), and it renders my dashboard unavailable.
    Agh. I don't know what's wrong. Maybe it is minor mark-up related? Things in the wrong order? Again, I am a php beginner.
    If anyone could give me some advice that would be GREATLY appreciated.

    Here's my code:

    function change_widgetized_area($content) {

    $content['Primary Aside']['args']['function']='child_1st_subsidiary_aside';
    $content['Secondary Aside']['args']['function']='child_2nd_subsidiary_aside';

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

    function child_1st_subsidiary_aside {
    if (is_active_sidebar('primary-aside') && is_home()) {
    echo thematic_before_widget_area('primary-aside');
    dynamic_sidebar('primary-aside');
    echo thematic_after_widget_area('primary-aside');
    }
    }

    function child_2nd_subsidiary_aside {
    if (is_active_sidebar('secondary-aside') && is_page()) {
    echo thematic_before_widget_area('secondary-aside');
    dynamic_sidebar('secondary-aside');
    echo thematic_after_widget_area('secondary-aside');
    }
    }

    Posted 3 years ago #
  28. hi dk

    with your code... there are two places you could amend...

    1. your declaration to call the blog:

    if (is_page() || is_home())

    is specific to your blog being the hompage i used

    if (is_archive() || is_single())

    instead... and it worked.

    2.
    in the following, the functions do not match the function is "change_secondary_aside" but you close as "childtheme_primary_aside"

    function change_secondary_aside($content) {
    $content['Primary Aside']['function'] = 'childtheme_primary_aside';
    return $content;
    }
    add_filter('thematic_widgetized_areas','change_primary_aside');

    Posted 3 years ago #
  29. I am trying to place my blog description into the very top of the Primary aside area. Im guessing there is a way I can filter widget_area_primary_aside() to do this, but would just like some advise. I'm essentially trying to reproduce a 'text' widget with this info hard coded.

    Thanks

    Rhys

    Posted 3 years ago #
  30. Maren, did you ever figure this out? I am trying to do the same thing (and I'm really new to PHP). I want the primary sidebar for the home page and the secondary on all the rest - I think I might just be calling the wrong things for the pages names? This thread was really helpful, I'm just not quite there :)

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.