Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Modifications to page.php to support subpage sidebars
Browse files Browse the repository at this point in the history
  • Loading branch information
jmr06005 committed Jun 24, 2014
1 parent 97d124e commit 23457e9
Showing 1 changed file with 63 additions and 90 deletions.
153 changes: 63 additions & 90 deletions page.php
Original file line number Diff line number Diff line change
@@ -1,90 +1,63 @@
<?php
/**
* The template for displaying all pages.
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site will use a
* different template.
*
* @package cornerstone
*/

get_header(); ?>
<h1>page.php</h1>
<?php
// sidebar custom field check.
$sidebar = get_post_meta( get_the_ID(), 'sidebar', true );

?>
<div class="row">

<!--

#phpneeded

If dynamic_sidebar() =! false/null...

<div class="col-sm-9">

else

<div class="col-sm-12">

-->
<div class="col-sm-9">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<h1>Sidebar?</h1>
<?php
$side = dynamic_sidebar(apply_filters( 'ups_sidebar', 'default-sidebar-id' ) );
if ($side !=null)

echo '<h1>'.$side.' </h1>';
?>
<?php while ( have_posts() ) : the_post(); ?>

<?php get_template_part( 'content', 'page' ); ?>

<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() ) :
comments_template();
endif;
?>

<?php endwhile; // end of the loop. ?>

</main><!-- #main -->
</div><!-- #primary -->
</div>
<!--

#phpneeded

If dynamic_sidebar() =! false/null...

<div class="col-sm-3">
<?php //dynamic_sidebar( apply_filters( 'ups_sidebar', 'default-sidebar-id' ) ); ?>
<?php //get_sidebar(); ?>
</div>


-->

<div class="col-sm-3">
<?php
$sidebar = get_post_meta( get_the_ID(), 'sidebar', true );
echo '<h1>'.$sidebar.'</h1>';
if ($sidebar == null){
echo '<h1>NULL</h1>';
}
if ( is_active_sidebar( $sidebar ) ) {
?>
<?php dynamic_sidebar( $sidebar ); ?>
<?php }
//<?php dynamic_sidebar( apply_filters( 'ups_sidebar', 'default-sidebar-id' ) ); ?>
<?php //get_sidebar(); ?>
</div>
</div>
<?php get_footer(); ?>
<?php
/**
* The template for displaying all pages.
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site will use a
* different template.
*
* @package cornerstone
*/

get_header(); ?>
<h1>page.php</h1>
<?php
// sidebar custom field check.
$sidebar = get_post_meta( get_the_ID(), 'uc_sidebar', true );
if( !is_active_sidebar( $sidebar ) ){
foreach(get_post_ancestors(get_the_ID()) as $ancestor){
$parent_sidebar = get_post_meta( $ancestor, 'uc_sidebar', true );
$parent_sidebar_children = get_post_meta( $ancestor, 'uc_sidebar_children', true );
if( is_active_sidebar( $parent_sidebar ) && $parent_sidebar_children != '' && $parent_sidebar_children ){
$sidebar = $parent_sidebar;
break;
}
}
}
?>
<div class="row">
<div class="col-sm-<?php echo (is_active_sidebar( $sidebar )?9:12); ?>">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<h1>Sidebar?</h1>
<?php
$side = dynamic_sidebar(apply_filters( 'ups_sidebar', 'default-sidebar-id' ) );
if ($side !=null)

echo '<h1>'.$side.' </h1>';
?>
<?php while ( have_posts() ) : the_post(); ?>

<?php get_template_part( 'content', 'page' ); ?>

<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() ) :
comments_template();
endif;
?>

<?php endwhile; // end of the loop. ?>

</main><!-- #main -->
</div><!-- #primary -->
</div>
<?php
if ( is_active_sidebar( $sidebar ) ) {
echo '<div class="col-sm-3">';
dynamic_sidebar( $sidebar );
echo '</div>';
} ?>
</div>
<?php get_footer(); ?>

0 comments on commit 23457e9

Please sign in to comment.