ThemeShaper Forums » Thematic

[closed]

Create widget areas below my lefted vertical menu

(4 posts)
  • Started 2 years ago by pm
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. pm
    Member

    Hello all. Sorry for my problem which seems to me a bit tricky.

    I've my vertical menu which is positioned (fixed) at the left of the website (div #access into the #wrapper)

    I would like to add widget areas (3-4) below this vertical navigation menu and inject these widgets into the Div #access.

    Is it possible to do that? Am i crazy?

    Posted 2 years ago #
  2. right on the front page of the forum:
    http://forums.themeshaper.com/topic/something-new-bout-widgetized-areas

    how to add a widget area is in there. but you'll need extra trickery to get inside #access

    you'd have to override access and rewrite it to add an action hook, then use that hook when defining your widget.

    Posted 2 years ago #
  3. pm
    Member

    @helga
    Thanks for your answer

    Sorry, but i'm kind of a functions/php newbie. So i got my widget area working with this code :

    // This will create your widget area
    function my_widgets_init() {
        register_sidebar(array(
           	'name' => 'Submenu',
           	'id' => 'submenu',
           	'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 widget area to your child theme
    function submenu_widgets() {
    if ( function_exists('dynamic_sidebar') && is_sidebar_active('submenu') ) {
        echo '<div id="submenu" class="aside">'. "\n" . '<ul class="xoxo">' . "\n";
        dynamic_sidebar('submenu');
        echo '' . "\n" . '</div><!-- #submenu .aside -->'. "\n";
    	}
    }
    add_action('thematic_abovecontainer','submenu_widgets');

    But i would like to put it inside the #access Div which is located in the wrapper :

    <body>
    
    <div id="header"></div>
    <div id="wrapper">
        <div id="access"></div>
        <div id="submenu"></div>
        <div id="container"></div>
        <div id="primary"></div>
    </div>
    <div id="footer"></div>
    
    </body>

    I tested a lot of things but don't find the way #submenu in #access.

    Thanks for your help.

    Posted 2 years ago #
  4. as i suggested you need to override the thematic_access() function that is creating the #access div. don't touch, but look around the extensions folder... you'll see all the behind-the-scenes power. you'll also notice a whole slew of functions that take the form of

    if (function_exists('childtheme_override_some_function'))  {
    	    function thematic_some_function() {
    	    	childtheme_override_some_function();
    	    }
    	} else {
    		function thematic_some_function() {
    			echo "some function here!";
    		}
    	}

    this means that anywhere you want to override something you can copy the thematic_some_function() function into your functions.php and rename it to childtheme_override_some_function().

    as i said, you need to add an action hook inside of access. so you need to override thematic_access() like so (oh and you'll need to define the action hook)

    // define action hook inside the #access div
    function kia_access_widget_area() {
        do_action('kia_access_widget_area');
    } // end kia_access_widget_area
    
    //override thematic_access
    function childtheme_override_thematic_access() { ?>
    
        <div id="access">
    
        	<div class="skip-link"><a href="#content" title="<?php _e('Skip navigation to the content', 'thematic'); ?>"><?php _e('Skip to content', 'thematic'); ?></a></div><!-- .skip-link -->
    
        	<?php 
    
        	if ((function_exists("has_nav_menu")) && (has_nav_menu(apply_filters('thematic_primary_menu_id', 'primary-menu')))) {
        		echo  wp_nav_menu(thematic_nav_menu_args());
       		} else {
       			echo  thematic_add_menuclass(wp_page_menu(thematic_page_menu_args()));
       		}
    
    		// here's our new hook
    		kia_access_widget_area();
        	?>
    
    	</div><!-- #access -->
    
    <?php }

    lastly you'll add your new widget to this new hook instead of above_container

    // This will create your widget area
    function my_widgets_init() {
        register_sidebar(array(
           	'name' => 'Submenu',
           	'id' => 'submenu',
           	'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 widget area to your child theme
    // adjust action hook to newly created hook
    function submenu_widgets() {
    if ( function_exists('dynamic_sidebar') && is_sidebar_active('submenu') ) {
        echo '<div id="submenu" class="aside">'. "\n" . '<ul class="xoxo">' . "\n";
        dynamic_sidebar('submenu');
        echo '' . "\n" . '</div><!-- #submenu .aside -->'. "\n";
    	}
    }
    add_action('kia_access_widget_area','submenu_widgets');

    completely untested. so be wary of typos.

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.