getdave / Tanlinell

Boilerplate Wordpress theme for rapid development of new WP themes. Based on the great work of the _s ("Underscore") theme.
GNU General Public License v2.0
6 stars 2 forks source link

Standard Definition for sidebar #152

Closed neilberry001 closed 11 years ago

neilberry001 commented 11 years ago
<aside class="menu-sub">

    <?php 
        $curr_pageid    = get_the_ID(); 
        $root_parent_id = tanlinell_get_root_parent( $curr_pageid, 'page');
        $children       = wp_list_pages( 'depth=2&title_li=&child_of=' . $root_parent_id . '&echo=0' );

        $section_title = (get_the_title($root_parent_id)) ? get_the_title($root_parent_id) : 'In this section';
    ?>

    <?php if( $children ){ ?>
        <div class="menu-secondary">
            <h4 class="menu-sub__heading"><?php echo $section_title ?></h4>
            <ul class="nav-sub">
            <?php echo $children; ?>
            </ul>
        </div>
    <?php } ?>  

</aside>

Should this be included in addition to the already in place code for widget pull. Or should this become the only contents? @getdave

getdave commented 11 years ago

@neilberry001 Should be included as separate partial within the main sidebar.php template as it might need to be included in different (custom) sidebar templates. So yes should sit alongside (above) the two widget area calls.

We rarely use widgets but should we need to then it's important they are there.

Markup

<aside class="menu-sub">
    <h4 class="menu-sub__heading"><?php echo esc_html($section_title); ?></h4>
    <ul class="nav-sub">
    <?php echo $children; ?>
    </ul>
</aside>

Wondering whether we should consider creating a function which generates navigation based on a CPT being based in.

neilberry001 commented 11 years ago

Note:

makes all lowercase

neilberry001 commented 11 years ago

Sidebar for Custom Post Types

<?php
    $pt_obj = get_post_type_object( 'accommodation' );

    //requires cpt to be defined as 'hierarchical' => true
    $args = array(
      'post_type'=>$pt_obj->name,
      'title_li'=> false,
      'echo'=>0
    );
    $list_pages      = wp_list_pages( $args ); 

    $section_title = $pt_obj->name;
?>

<?php if( $list_pages ) : ?>
    <aside class="menu-sub">
        <h4 class="menu-sub__heading"><?php echo ucwords(esc_html($section_title)); ?></h4>
        <ul class="nav-sub">
        <?php echo $list_pages; ?>
        </ul>
    </aside>
<?php endif; ?>
neilberry001 commented 11 years ago

These two options should be need matching. cpt option uses $args not string, would be nice to have them match.

neilberry001 commented 11 years ago

further: Categories List:

<?php 
    $args = array (
        'echo'      =>0,
        'title_li'  =>false,

    );
    $categories_list= wp_list_categories( $args );

    $section_title = 'Categories';
?>

<?php if( $categories_list ) : ?>
<aside class="menu-sub">
    <div class="menu-secondary">
        <h4 class="menu-sub__heading"><?php echo ucwords(esc_html($section_title)); ?></h4>
        <ul class="nav-sub">
        <?php echo $categories_list; ?>
        </ul>
    </div>
</aside>
<?php endif; ?> 
neilberry001 commented 11 years ago

further Archive List:

<?php 
    $args = array (
        'echo'      =>0,
        'title_li'  =>false,        
    );
    $categories_list= wp_get_archives( $args );

    $section_title = 'Archives';
?>

<?php if( $categories_list ) : ?>
<aside class="menu-sub">
    <div class="menu-secondary">
        <h4 class="menu-sub__heading"><?php echo ucwords(esc_html($section_title)); ?></h4>
        <ul class="nav-sub">
        <?php echo $categories_list; ?>
        </ul>
    </div>
</aside>
<?php endif; ?> 
neilberry001 commented 11 years ago

This should allow us to build a consistent sidebar with all options available as default in Tanlinell.

It is advised that the above blocks be commented for documentation and 'prettified' so are consistent with each other.