ThemeShaper Forums » Thematic

[closed]

custom side-by-side widgets

(7 posts)
  • Started 1 year ago by candregg
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. I am trying to add several widgets to the Thematic child theme sidebar. Some have worked; some not. I have successfully added a custom widget above the Primary. Now I am trying to add a Left and Right widget side-by-side between the primary and secondary widget areas.

    Here is the function code (in parts):

    // Add additional Widget
    // Create your widget area
    function my_widgets_init() {
        register_sidebar(array(
           	'name' => 'Community',
           	'id' => 'community',
           	'before_widget' => '<li id="%1$s" class="widgetcontainer %2$s">',
           	'after_widget' => "",
    		'before_title' => "<h3 class=\"widgettitle\">",
    		'after_title' => "</h3>\n",
        ));
    
        register_sidebar(array(
           	'name' => 'Left',
           	'id' => 'left',
           	'before_widget' => '<li id="%1$s" class="widgetcontainer %2$s">',
           	'after_widget' => "",
    		'before_title' => "<h3 class=\"widgettitle\">",
    		'after_title' => "</h3>\n",
        ));
    
        register_sidebar(array(
           	'name' => 'Right',
           	'id' => 'right',
           	'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 my_community_widget() {
        echo '<div id="community" class="aside">'?>
        <ul class="community">
    </code>
    <code>
    <li><a href="#"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rss.png" width="32" height="32" /></a></li>
    <li><a href="#"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/email.png" width="32" height="32" /></a></li>
    <li><a href="#"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/facebook.png" width="32" height="32" /></a></li>
    <li><a href="#"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/twitter.png" width="32" height="32" /></a></li>
    <li><a href="#"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/linkedin.png" width="32" height="32" /></a></li>
    <li><a href="#"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/youtube.png" width="32" height="32" /></a></li>
        </div>
    	<?php
    }
    
    add_action('thematic_abovemainasides','my_community_widget');
    
    //  Adding Left and Right Widgets
    
    function my_left_widget() {
    if ( function_exists('dynamic_sidebar') && is_sidebar_active('left') ) {
        echo '<div id="left" class="aside">'. "\n" . '<ul class="xoxo">' . "\n";
        dynamic_sidebar('left');
        echo '' . "\n" . '</div><!-- #left .aside -->'. "\n";
    }
    }
    add_action('thematic_betweenmainasides','my_left_widget');
    
    function my_right_widget() {
    if ( function_exists('dynamic_sidebar') && is_sidebar_active('right') ) {
        echo '<div id="right" class="aside">'. "\n" . '<ul class="xoxo">' . "\n";
        dynamic_sidebar('right');
        echo '' . "\n" . '</div><!-- #right .aside -->'. "\n";
    }
    }
    add_action('thematic_betweenmainasides','my_right_widget');

    Here is the css:

    #left {
    	margin: 0;
    	padding: 12px;
    	width: 126px;
    	float: left;
    }
    
    #right {
            margin:0;
            padding:12px;
    	float: right;
    	width: 126px;
    }

    The Community widget went in perfectly, and looks great! Further down, while the Left and Right widget areas appear in the Admin area, only the Left widget content is visible on the webpage. Please see http://seacliffmm.com/prod/indigest/admin/.

    Any help?

    Once I get this one figured out, I need to make six different Primary widget areas that will appear based on which category or page is active. That will be another topic.

    Thanks!

    Caron

    Posted 1 year ago #
  2. there isn't a right widget in your markup. you might not have a widget in it.

    Posted 1 year ago #
  3. The widget exists in the admin area, and I have it populated with content almost identical to that in Left. I have also verified that the content exists.

    But, no, it doesn't show in the source code or online. That's the problem. What I need to figure out is Why. And of course, how to fix it.

    Posted 1 year ago #
  4. bogh
    Member

    HI,

    Here is a thematic widget like I use it:

    class Footer_Text_Widget extends WP_Widget {
    function Footer_Text_Widget() {
    		$widget_ops = array('classname' => 'widget_footer_text', 'description' => __( "Add some text to your footer.") );
    		$this->WP_Widget('footer_text_widget', __('Footer_Text_Widget', 'thematic'), $widget_ops);
    	}
    function update($new_instance, $old_instance) {
    		// processes widget options to be saved
    		return $new_instance;
    	}
    function widget($args, $instance) {
    		// outputs the content of the widget
    		extract($args);
    
    		echo $before_widget;
    		?>
    			<?php echo $before_title; ?><?php echo $footer_text_widget_title; ?><?php echo $after_title; ?>
    			<ul>
    				<li>//Your Code Here</li>
    			</ul>
    		<?php
    		echo $after_widget; }
    		}
    }
    register_widget('Footer_Text_Widget');
    Posted 1 year ago #
  5. well had to ask the obvious esp, b/c i just dropped this into my local install and the widgets do appear in the markup as expected. so there is something else going on here. try putting a different widget in the right sidebar?

    Posted 1 year ago #
  6. I changed the padding and margins of the containing widgetareas and it finally worked. Thanks! Now on to those conditional Primary widget variants...

    Posted 1 year ago #
  7. well as i mentioned in the something new bout widgets thread... its all the same except for where you have your conditionals

    add an extra condition to this to make it only display in certain places

    if ( function_exists('dynamic_sidebar') && is_sidebar_active('right') ) {
    Posted 1 year ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.