WordPress.org

Ready to get started?Download WordPress

Forums

Dynamic Sidebar help (9 posts)

  1. cappware
    Member
    Posted 4 years ago #

    WordPress: v2.9.2
    Theme: Intrepdity
    Site: http://www.capp-ware.com/wordpress (temporary install for config)

    As I have mentioned in my other posts, I'm a beginner to WordPress and all that comes with it.

    I need help with creating a dynamic sidebar for starters, then I need help with calling these based on what page is visible.

    I have several pages, that will have several pages under them. Well, I don't want to force potential customers to have to go through the entire navigation menu up top to go from say, screenshots to downloads. So, i want to create a sidebar for that particular page that will include links to the sub-pages.

    Someone pointed me to this link: http://www.ericlightbody.com/2009/04/30/adding-multiple-sidebars-and-other-elements-to-your-wordpress-theme/
    And although it has some good information, it is for an older version of wordpress, so the look and layout are completely different. Also, the article makes references to editing files that my theme does not have.

    So, I am in need of quite a bit of help. I know a little web coding and I understand what I'm looking at, but having to create it from scratch is beyond me right now.

    Thank you in advance for your help.

  2. esmi
    Forum Moderator
    Posted 4 years ago #

  3. cappware
    Member
    Posted 4 years ago #

    Thanks for the links...but, what do they mean. As I said, I'm new to this.

    The info in those links is really confusing.

  4. esmi
    Forum Moderator
    Posted 4 years ago #

    It's all the info you need to create your dynamic sidebars. You could also try downloading a few free themes and looking at how the sidebars have been created.

  5. cappware
    Member
    Posted 4 years ago #

    I did download a free theme. I installed and configured the Intrepidity theme because it fits my business colors best.

    I read through those articles and recall seeing this quote a time or two: "If you can't answer these questions, maybe someone will be nice enough to help you on the forums"

    Well, that is why I am here asking for help. I read a lot about these before posting my question. It seems these articles assume you already know how to build a theme/widgets from scratch. I don't.

    Using my existing theme (Intrepidity), I have no idea where to start with doing this.

  6. cappware
    Member
    Posted 4 years ago #

    Update, after some searching, I found at least the parts of the code mentioned in the article I posted in the first post.
    But, I know that just throwing in someone else's code will more than likely screw something up.

    Here is the basics of what I want:
    1) User clicks on page
    2) Sidebar shows links to all sub-pages for that page
    3) All sub-pages show those same links, like a mini nav menu?

    Please help me

  7. photocurio
    Member
    Posted 4 years ago #

    i am pretty new to wordpress and i'm basically a themer who knows just enough about php to not want to touch it more than i have to. i disabled the dynamic sidebar in my latest site, and it was a lot easier to set up:
    http://mumford-photo.com/wordpress/

    I strip out lots of php code that i don't understand and am left with a bare-bones loop that i can edit. it is amazing that this method works! wordpress seems very robust.

    my advice is: unless you know php code pretty well, i'd make your sidebar as simple as possible.

    a book that i've found very helpful is Smashing WordPress.

  8. cappware
    Member
    Posted 4 years ago #

    Alright, I have begun to try this myself. Since its not a live site, I can afford to mess it up and start over if needed. Below is what I've done so far going by all the examples and tutorials. But it does not work.

    Going by the example in the link I put in the first post, I added this code to my functions.php

    register_sidebar(array('name'=>'RememberMe', 'before_widget' => '<li class="widget" id="%1$s">', 'after_widget' => '</li>',	'before_title' => '<h2><a href="#" rel="nofollow" class="sidebartitle">', 'after_title' => '</a></h2>'));
    register_sidebar(array('name'=>'WatchYourIP', 'before_widget' => '<li class="widget" id="%1$s">', 'after_widget' => '</li>',	'before_title' => '<h2><a href="#" rel="nofollow" class="sidebartitle">', 'after_title' => '</a></h2>'));

    Then, at the bottom of the Functions.php file, I added this:

    function getTopParentPostName($myid) {
    $mypage = get_page($myid);
    
    if ($mypage->post_parent == 0){
    return $mypage->post_name;
    }
    else{
    return getTopParentPostName($mypage->post_parent);
    }
    }
    
    function is_tree( $p_name ) {    // $p_name = The page we're looking for pages underneath
    global $post;       // We load this as we're outside of the post
    $top_post_name = getTopParentPostName($post);
    
    if ( $p_name == $top_post_name ) return true;
    else return false;
    }

    I added this to my Sidebar.php

    if ( is_tree('rememberme') ) {
    if (!function_exists('dynamic_sidebar') || !dynamic_sidebar( 'RememberMe') ) { $generic_sidebar = true; }
    }
    elseif ( is_tree('watchyourip')) {
    if (!function_exists('dynamic_sidebar') || !dynamic_sidebar( 'WatchYourIP') ) { $generic_sidebar = true; }
    }
  9. cappware
    Member
    Posted 4 years ago #

    Am I doing something wrong by asking for additional help with this?

    I've commented twice now to see it is gone.

    Can anyone look at my code above and see if I am doing it wrong? I've tried following the examples provided, but they seem to all assume I can already create my own theme or widgets. I'm a newcomer to the world of WordPress and need help.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.