Skip to:
Content
Pages
Categories
Search
Top
Bottom

I would add a fourth-section, but the widgets?


  • alcina22
    Participant

    @alcina22

    Hello everyone, :)

    I would add a fourth section to my theme for the moment I added this code in home.php file:

    <div id=”fourth-section” class=”widget-section”>

    <?php if ( !function_exists(‘dynamic_sidebar’)

    || !dynamic_sidebar(‘first-section’) ) : ?>

    <div class=”widget-error”>

    <?php _e( ‘Please log in and add widgets to this section.’, ‘buddypress’ ) ?> /wp-admin/widgets.php?s=&show=&sidebar=first-section”><?php _e( ‘Add Widgets’, ‘buddypress’ ) ?>

    </div>

    <?php endif; ?>

    </div>

    and it’s ok, I see a div with a link “add widgets” that I refer to the panel dell’admin correctly;

    but what do I do to ensure that I appear here this fourth section, and so I really can add widgets?

    I hope you will help me, thanks a lot!

    a.

Viewing 7 replies - 1 through 7 (of 7 total)

  • 21cdb
    Participant

    @21cdb

    In ur themes function.php (create one if it doesn’t exist in ur theme folder) add

    <br />
    /* Register an additional fourth widget column */<br />
    register_sidebars( 1,<br />
    array(<br />
    'name' => 'fourth-section',<br />
    'before_widget' => '<div id="%1$s" class="widget %2$s">',<br />
    'after_widget' => '</div>',<br />
    'before_title' => '<h2 class="widgettitle">',<br />
    'after_title' => '</h2>'<br />
    )<br />
    );<br />

    and alter the code in ur post above to

    <div id="fourth-section" class="widget-section"><br />
    <?php if ( !function_exists('dynamic_sidebar')<br />
    || !dynamic_sidebar('fourth-section') ) : ?></p>
    <p> <div class="widget-error"><br />
    <?php _e( 'Please log in and add widgets to this section.', 'buddypress' ) ?> /wp-admin/widgets.php?s=&show=&sidebar=first-section"><?php _e( 'Add Widgets', 'buddypress' ) ?><br />
    </div></p>
    <p> <?php endif; ?></p>
    <p> </div>

    This should bring u a functional fourth-section sidebar in the wordpress backend. Valid for BP 1.1.3 Theme.

    Are all those br tags intentional?


    21cdb
    Participant

    @21cdb

    Yes they are. Sorry!


    alcina22
    Participant

    @alcina22

    thank you so much! :)

    I will try, tomorrow.

    (I’m late, sorry, I was out the town for the holidays…)

    ciao!

    A.


    alcina22
    Participant

    @alcina22

    I have tried in various ways this morning, but the new file functions.php don’t work … :-(

    First I tried with functions.php “child” identical to that in BP-sn-parent only pasted the piece of code you told me, but gave me error at the first “br” , because: “unaspected” “<” , it said …

    Then I tried to remove the “br” the but gave me a blank page.

    Then I tried with a file functions.php child only with the code that you gave me; it don’t work, you can see the code printed on the page of the site. (here… http://diogenesearch.net/)

    And when I add <?php in the first line and <? in the last gives me error.

    I do not know what can I do now…

    Where I go wrong? help me again, please …!

    thank you, thank you very much!

    Ciao :-)

    A.

    I’m not sure why there were br tags outside the quote marks in the code above. That’s HTML, not PHP. This is the code I’m using in my child functions.php file (below). It works. It’s for the BP 1.2 theme (which only has one sidebar). So I’m basically just creating two new sidebar areas (Member and Public) and then unregistering the default sidebar from the parent theme (which again… is the BP 1.2 default theme).

    <?php

    /* Register Sidebars */
    if ( function_exists('register_sidebar') ) {
    register_sidebar(array(
    'name' => 'Public',
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h3 class="widgettitle">',
    'after_title' => '</h3>'
    ));
    register_sidebar(array(
    'name' => 'Member',
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h3 class="widgettitle">',
    'after_title' => '</h3>'
    ));
    }

    /* Unregister Parent Sidebar */
    function remove_sidebar() {
    unregister_sidebar('sidebar-3');
    }
    add_action( 'admin_init', 'remove_sidebar');

    ?>

    To display these widget areas in your pages, just add this where ever you want in your templates (most likely in the sidebar.php file).

    <?php if ( !dynamic_sidebar( 'Public' ) ) : endif; ?>
    <?php if ( !dynamic_sidebar( 'Member' ) ) : endif; ?>

    Of course… I also have this wrapped with if (is_user_logged_in()) since in my case, I want a different sidebar for logged in users vs. logged out users. Just modify the above for your needs.


    alcina22
    Participant

    @alcina22

    Dear friends, I solved!

    I added like you said a functions.php file in my theme, only with this code:

    <?php

    /* Register my widget 4 column */

    register_sidebars( 1,

    array(

    ‘name’ => ‘zero-section’,

    ‘before_widget’ => ‘<div id=”%1$s” class=”widget %2$s”>’,

    ‘after_widget’ => ‘</div>’,

    ‘before_title’ => ‘<h2 class=”widgettitle”>’,

    ‘after_title’ => ‘</h2>’

    )

    );

    ?>

    ciao and thank you for your inputs and your help!

    A.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘I would add a fourth-section, but the widgets?’ is closed to new replies.
Skip to toolbar