WP Framework Forums

A blank WordPress Theme Framework

Register or log in - lost password?

WP Framework Forums » General Discussion

Adding a second sidebar to wpframework theme

(7 posts) (6 voices)
  • Started 1 year ago by
  • Latest reply from Alkymst
  • 1 Members Subscribed To Topic
  • Related Topics:
    1. How do I add new sidebars? create_widget_area() doesn't work
    2. How can I actually modifiy the sidebar's CSS?
    3. Registering sidebars
    4. How I can make this theme a 3 colums, 160-480-160px.
    5. Styles for Page Specific Templates

Tags:

  • add
  • areas
  • mulitple
  • New Sidebar
  • New Widgets
  • register a widget
  • register sidebar
  • sidebar
  • sidebars
  • template
  • widget
  1. Anonymous
    Unregistered

    I have tried to add a second dynamic sidebar to the theme but I cant get it to work properly. Does anybody have any step by step instructions on how to do this?

    Posted 1 year ago #
  2. Ptah Dunbar
    Framework Overlord

    What version of WP Framework are you using?

    Using the latest stable version of WP Framework 0.2.3, here's how that works.

    First, you want to change this line found in functions.php
    define( 'REGISTER_WIDGETS', 1 );
    Change the 1 to the number of widgets you'd like to add.

    Next, you add dynamic_sidebars() to your templates. e.g.


    <?php /* Widgetized Area */
    if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar() ) : ?>
    <!-- you can have stuff display here by default. if not, just leave this blank. -->
    <?php endif; /* (!function_exists('dynamic_sidebar') */ ?>

    You add those to your template based on the number of widgets you'd like to add.

    And that's it. Check the widgets panel and you should see all the new widgets show up.

    Now if you'd like to customize the output of the widgets, simply add this to your custom-functions.php:

    function register_widgets() {
    register_sidebars( REGISTER_WIDGETS, array(
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ));
    }

    And there you go.

    Posted 1 year ago #
  3. Red Electric
    Member

    Hi Ptah,

    Thanks for creating and sharing this awesome theme,framework.. I've been wanting to have a go at building a theme for ages.

    I noticed this post and I too wanted to have a second sidebar, but I followed your instructions, however it doesn't seem to make any difference.

    Basically I just want a second column that I can put stuff in, (it doesn't have to be widgeted) is the process still the same?

    Thanks

    Martin

    Posted 1 year ago #
  4. Ptah Dunbar
    Framework Overlord

    To add a regular sidebar, simply write something like this:


    include( TEMPLATEPATH . '/custom-sidebar.php' );

    Create a new file called custom-sidebar.php in the root directory and create your div in there.

    Posted 1 year ago #
  5. franklores
    Member

    Hello I tried to follow these instructions but no luck. I am using version 0.2.4.

    Any advice?

    Thanks,

    Frank

    Posted 1 year ago #
  6. oliver
    Member

    no´t working for me :S but im add this to work

    my wpframework vercion is 0.2.4
    in \library\functions\widgets.phpb line: 24

    change this:

    $how_many = apply_filters( 'register_widgets_count', (int) 1 ); // Available filter: widget_count

    to this for add 6 Widgetized Areas:

    $how_many = apply_filters( 'register_widgets_count', (int) 6 ); // Available filter: widget_count

    and this to work in differents part of my template: in dynamic_sidebar(1) one is the ID of widget

    <?php /* Widgetized Area */
    if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar(1) ) : ?>
    <!-- you can have stuff display here by default. if not, just leave this blank. -->
    <?php endif; /* (!function_exists('dynamic_sidebar') */ ?>

    this working great but is correct?? I'm not sure

    thx for this great Framework :)

    Posted 10 months ago #
  7. Alkymst
    Member

    So if you want to make it easy.

    On widgets.php

    Replace the "register_widgets" function w/


    function register_widgets($name=null, $id=null) {
    $defaults = array(
    'name' => null,
    'id' => null,
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    );
    $defaults["name"] = $name;
    $defaults["id"] = $id;
    $args = apply_filters( 'register_widgets', (array) $defaults ); // Available filter: register_widgets
    $how_many = apply_filters( 'register_widgets_count', (int) 1 ); // Available filter: widget_count
    register_sidebars( $how_many, $args );
    }

    Then in your custom-function.php you can just call the function like:


    register_widgets('New Widget Area 1','New Widget Area 1');
    register_widgets('New Widget Area 2','New Widget Area 2');

    To display it in your template file you would


    <?php if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar('New Widget Area 1') ) : ?>
    <p>Missing the New Widget Area!!!</p>
    <?php endif; /* (!function_exists('dynamic_sidebar') */ ?>

    Posted 10 months ago #

RSS feed for this topic

Reply

You must log in to post.

WP Framework Forums is proudly powered by bbPress.