Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1558

    Hi, Just getting to grips with wordpress, and the avisio template – I’m hitting a wall in regards to the sidebar submen:

    I want the sidebar sub menu to display the children of *only* it’s parent page. eg:

    if we are on the ABOUT top level page, the sub-menu would be :

    ABOUT (current page)

    – More Info

    – something else

    – etc.

    I can see how to create multiple other menus in Appearance/Menus, but as far as I can tell, I can only add one menu to the sidebar, and the choice is that it will display over *ALL* pages regardless of the parent page. Is this correct? it makes navigation hard – there must be a solution?

    In short: I’d like to be able to assign different sub menus to different pages..

    #35651

    You could create specifc widget areas under Avisio Options > Sidebar & Footer — Extra Widget Areas for specific Pages.

    #35652

    That’s horribly clunky solution – it works, but it means that I would have to make a separate menu, and separate widget for EVERY SINGLE PAGE. As a site grows, it would become completely unmanageable.

    Haha, surely this is such a common way of presenting sub-navigation it must have been tackled in a better way?

    #35653

    You could use a code like:

    <?php
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0");
    echo $children; ?>

    in your sidebar.php to display the pages in the way you want.

    #35654

    Sorry, I’m not a PHP programmer (just frontend, but I can muddle a bit) what would that code do?

    #35655

    It would list all childrens of the current page – you can put this code into your sidebar.php and list all subpages of a current page.

    #35656

    I’ve tried adding that – but it doesn’t doe anything but it breaks the page depending where I put it – here is the code for sidebar.php:

    <?php
    global $k_option, $custom_widget_area;
    if ($k_option['custom']['bodyclass'] == "") // check if its a full width page, if full width dont show the sidebar content
    {
    ##############################################################################
    # Display the sidebar menu
    ##############################################################################

    $default_sidebar = true;

    echo "<div class='sidebar'>";
    echo "<span class='sidebar_top'><!-- needed for smooth start of sidebar background--></span>";
    echo "<span class='sidebar_bottom'><!-- needed for smooth end of sidebar background--></span>";

    //Frontpage sidebars:
    if ($k_option['showSidebar'] == 'frontpage' && dynamic_sidebar('Frontpage Sidebar') ) : $default_sidebar = false; endif;

    // general blog sidebars
    if ($k_option['showSidebar'] == 'blog' && dynamic_sidebar('Sidebar Blog') ) : $default_sidebar = false; endif;

    // general pages sidebars
    if ($k_option['showSidebar'] == 'page' && dynamic_sidebar('Sidebar Pages') ) : $default_sidebar = false; endif;

    //unique Page sidebars:
    if (function_exists('dynamic_sidebar') && dynamic_sidebar('Page: '.$custom_widget_area) ) : $default_sidebar = false; endif;

    //unique Category sidebars
    if (function_exists('dynamic_sidebar') && dynamic_sidebar('Category: '.$custom_widget_area) ) : $default_sidebar = false; endif;

    //sidebar area displayed everywhere
    if (function_exists('dynamic_sidebar') && dynamic_sidebar('Displayed Everywhere')) : $default_sidebar = false; endif;

    //default dummy sidebar
    if ($default_sidebar && $k_option['includes']['dummy_sidebars'] == 1)
    {

    if(is_page()){
    ?>
    <div class="box_small box widget community_news"><h3 class="widgettitle">Features we offer</h3>
    <div class="entry box_entry">
    <p><strong>Absolutley Striking Designs</strong><br/>Lorem ipsum dolor sit amet, usmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>

    <div class="entry box_entry">
    <p><strong>Multiple color options</strong><br/>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>

    <div class="entry box_entry">
    <p><strong>Unique Features</strong><br/>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor. Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>

    <!--end box-->
    </div>
    <?php dummy_widget(1); ?>

    <?php }else{ ?>
    <?php dummy_widget(1); ?>
    <?php dummy_widget(2); ?>
    <?php dummy_widget(3); ?>

    <?php
    }
    }
    echo "</div>";

    } ?>

    #35657

    Hey,

    The code @Dude provided should go just above //Frontpage sidebars: assuming you wanted to put it in the sidebar at the very top (before any widgets).

    To tidy it up a bit, I’d put it in the same container widgets go in and would look like this:

    <?php $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0");
    if ($children != "") { // conditional so only shows up if there are sub pages ?>
    <div class="box_small box widget">
    <h3 class="widgettitle">Sub Pages</h3><!-- You can remove this line if you don't want a title :) -->
    <div class="entry box_entry">
    <?php echo $children; ?>
    </div>
    </div>
    <?php } ?>

    Let me know how you get on :)

    James

    #35658

    Ok, tried that – it results in the sidebar and footer completely disappearing… aaargghh!

    I’ve tried it everywhere, nothing works..

    <?php
    global $k_option, $custom_widget_area;
    if ($k_option['custom']['bodyclass'] == "") // check if its a full width page, if full width dont show the sidebar content
    {
    ##############################################################################
    # Display the sidebar menu
    ##############################################################################

    $default_sidebar = true;

    echo "<div class='sidebar'>";
    echo "<span class='sidebar_top'><!-- needed for smooth start of sidebar background--></span>";
    echo "<span class='sidebar_bottom'><!-- needed for smooth end of sidebar background--></span>";

    <?php $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0");
    if ($children != "") { // conditional so only shows up if there are sub pages ?>
    <div class="box_small box widget">
    <h3 class="widgettitle">Sub Pages</h3><!-- You can remove this line if you don't want a title :) -->
    <div class="entry box_entry">
    <?php echo $children; ?>
    </div>
    </div>
    <?php } ?>
    //Frontpage sidebars:
    if ($k_option['showSidebar'] == 'frontpage' && dynamic_sidebar('Frontpage Sidebar') ) : $default_sidebar = false; endif;

    // general blog sidebars
    if ($k_option['showSidebar'] == 'blog' && dynamic_sidebar('Sidebar Blog') ) : $default_sidebar = false; endif;

    // general pages sidebars
    if ($k_option['showSidebar'] == 'page' && dynamic_sidebar('Sidebar Pages') ) : $default_sidebar = false; endif;

    //unique Page sidebars:
    if (function_exists('dynamic_sidebar') && dynamic_sidebar('Page: '.$custom_widget_area) ) : $default_sidebar = false; endif;

    //unique Category sidebars
    if (function_exists('dynamic_sidebar') && dynamic_sidebar('Category: '.$custom_widget_area) ) : $default_sidebar = false; endif;

    //sidebar area displayed everywhere
    if (function_exists('dynamic_sidebar') && dynamic_sidebar('Displayed Everywhere')) : $default_sidebar = false; endif;

    //default dummy sidebar
    if ($default_sidebar && $k_option['includes']['dummy_sidebars'] == 1)
    {

    if(is_page()){
    ?>
    <div class="box_small box widget community_news"><h3 class="widgettitle">Features we offer</h3>
    <div class="entry box_entry">
    <p><strong>Absolutley Striking Designs</strong>Lorem ipsum dolor sit amet, usmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>

    <div class="entry box_entry">
    <p><strong>Multiple color options</strong>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>

    <div class="entry box_entry">
    <p><strong>Unique Features</strong>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor. Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>

    <!--end box-->
    </div>
    <?php dummy_widget(1); ?>

    <?php }else{ ?>
    <?php dummy_widget(1); ?>
    <?php dummy_widget(2); ?>
    <?php dummy_widget(3); ?>

    <?php
    }
    }
    echo "</div>";

    } ?>

    #35659

    I corrected your code – it should work now.

    <?php
    global $k_option, $custom_widget_area;
    if ($k_option['custom']['bodyclass'] == "") // check if its a full width page, if full width dont show the sidebar content
    {
    ##############################################################################
    # Display the sidebar menu
    ##############################################################################

    $default_sidebar = true;

    echo "<div class='sidebar'>";
    echo "<span class='sidebar_top'><!-- needed for smooth start of sidebar background--></span>";
    echo "<span class='sidebar_bottom'><!-- needed for smooth end of sidebar background--></span>"; ?>

    <?php $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0");
    if ($children != "") { // conditional so only shows up if there are sub pages ?>
    <div class="box_small box widget">
    <h3 class="widgettitle">Sub Pages</h3><!-- You can remove this line if you don't want a title :) -->
    <div class="entry box_entry">
    <?php echo $children; ?>
    </div>
    </div>
    <?php }
    //Frontpage sidebars:
    if ($k_option['showSidebar'] == 'frontpage' && dynamic_sidebar('Frontpage Sidebar') ) : $default_sidebar = false; endif;

    // general blog sidebars
    if ($k_option['showSidebar'] == 'blog' && dynamic_sidebar('Sidebar Blog') ) : $default_sidebar = false; endif;

    // general pages sidebars
    if ($k_option['showSidebar'] == 'page' && dynamic_sidebar('Sidebar Pages') ) : $default_sidebar = false; endif;

    //unique Page sidebars:
    if (function_exists('dynamic_sidebar') && dynamic_sidebar('Page: '.$custom_widget_area) ) : $default_sidebar = false; endif;

    //unique Category sidebars
    if (function_exists('dynamic_sidebar') && dynamic_sidebar('Category: '.$custom_widget_area) ) : $default_sidebar = false; endif;

    //sidebar area displayed everywhere
    if (function_exists('dynamic_sidebar') && dynamic_sidebar('Displayed Everywhere')) : $default_sidebar = false; endif;

    //default dummy sidebar
    if ($default_sidebar && $k_option['includes']['dummy_sidebars'] == 1)
    {

    if(is_page()){
    ?>
    <div class="box_small box widget community_news"><h3 class="widgettitle">Features we offer</h3>
    <div class="entry box_entry">
    <p><strong>Absolutley Striking Designs</strong>Lorem ipsum dolor sit amet, usmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>

    <div class="entry box_entry">
    <p><strong>Multiple color options</strong>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>

    <div class="entry box_entry">
    <p><strong>Unique Features</strong>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor. Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>

    <!--end box-->
    </div>
    <?php dummy_widget(1); ?>

    <?php }else{ ?>
    <?php dummy_widget(1); ?>
    <?php dummy_widget(2); ?>
    <?php dummy_widget(3); ?>

    <?php
    }
    }
    echo "</div>";

    } ?>

    #35660

    OK! Thanks a lot for all the help BTW it is really appreciated.

    Not quite right yet though – the sub menu appears only on pages that have child pages. When you go on one of the child pages, How can we stilll get the menu to stay, and indicate which page we are currently on?

    Using your getting started content, when I’m on the about the theme page, I get:

    Sub Pages


    # Basic Shortcodes

    # Advanced Shortcodes

    # HTML Styles

    # Fullwidth & Columns

    # Popular Treatments

    # Tab Example

    # Even more Tabs

    which is perfect – however, when I click on one of those pages, the sub menu goes away.

    #35661

    You can use following code to achieve what you want:

    <?php
    global $k_option, $custom_widget_area;
    if ($k_option['custom']['bodyclass'] == "") // check if its a full width page, if full width dont show the sidebar content
    {
    ##############################################################################
    # Display the sidebar menu
    ##############################################################################

    $default_sidebar = true;

    echo "<div class='sidebar'>";
    echo "<span class='sidebar_top'><!-- needed for smooth start of sidebar background--></span>";
    echo "<span class='sidebar_bottom'><!-- needed for smooth end of sidebar background--></span>"; ?>

    <?php
    if($post->post_parent)
    $children .= wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->post_parent."&echo=0");
    else
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0");
    if ($children) { ?>
    <div class="widget widget_pages">

    <h3>Sub-Navigation</h3>
    <ul>
    <?php
    echo $children; ?>
    </ul>
    </div>
    <?php }

    //Frontpage sidebars:
    if ($k_option['showSidebar'] == 'frontpage' && dynamic_sidebar('Frontpage Sidebar') ) : $default_sidebar = false; endif;

    // general blog sidebars
    if ($k_option['showSidebar'] == 'blog' && dynamic_sidebar('Sidebar Blog') ) : $default_sidebar = false; endif;

    // general pages sidebars
    if ($k_option['showSidebar'] == 'page' && dynamic_sidebar('Sidebar Pages') ) : $default_sidebar = false; endif;

    //unique Page sidebars:
    if (function_exists('dynamic_sidebar') && dynamic_sidebar('Page: '.$custom_widget_area) ) : $default_sidebar = false; endif;

    //unique Category sidebars
    if (function_exists('dynamic_sidebar') && dynamic_sidebar('Category: '.$custom_widget_area) ) : $default_sidebar = false; endif;

    //sidebar area displayed everywhere
    if (function_exists('dynamic_sidebar') && dynamic_sidebar('Displayed Everywhere')) : $default_sidebar = false; endif;

    //default dummy sidebar
    if ($default_sidebar && $k_option['includes']['dummy_sidebars'] == 1)
    {

    if(is_page()){
    ?>
    <div class="box_small box widget community_news"><h3 class="widgettitle">Features we offer</h3>
    <div class="entry box_entry">
    <p><strong>Absolutley Striking Designs</strong>Lorem ipsum dolor sit amet, usmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>

    <div class="entry box_entry">
    <p><strong>Multiple color options</strong>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>

    <div class="entry box_entry">
    <p><strong>Unique Features</strong>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor. Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>

    <!--end box-->
    </div>
    <?php dummy_widget(1); ?>

    <?php }else{ ?>
    <?php dummy_widget(1); ?>
    <?php dummy_widget(2); ?>
    <?php dummy_widget(3); ?>

    <?php
    }
    }
    echo "</div>";

    } ?>

    #35662

    Thanks – I think that’s as close as I’m going to get it! It seems a little temperamental on some pages, but I will have a fiddle with the CSS etc. and see what I can do.

    It would be a fantastic idea to turn this functionality into a widget or plugin or something so you can have the choice to turn it on or off depending on the page – I’ve seen a few very similar requests on these forums, and it really helps bridge the gap between being a blog used for business info, and a proper website with cms – once you can get better control of sub menus, it makes such a difference to the navigation of a site.

    This is my first experience with wordpress, and it’s the only thing letting it down tbh.

    Can’t fault the support though, you guys have been really helpful.

    #35663

    Glad that we could help you.

Viewing 14 posts - 1 through 14 (of 14 total)

The topic ‘Different Sidebar submenu for each top level page??’ is closed to new replies.