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

Commit

Permalink
Browse files Browse the repository at this point in the history
Update to hale to hide private pages and adding list private pages te…
…mplate
  • Loading branch information
jmr06005 committed Jan 12, 2015
1 parent b551d3f commit 70da853
Showing 1 changed file with 90 additions and 76 deletions.
166 changes: 90 additions & 76 deletions page-az.php
@@ -1,76 +1,90 @@
<?php
/*
Template Name: A-Z Index
*/
get_header(); ?>
<?php include('inc/sidebar-check.php')?>

<div class="row">
<div class="span12">
<div class="row-fluid" id="primary">
<div class="span<?php echo (is_active_sidebar( $sidebar )?9:12); ?>">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post content clearfix" id="post-<?php the_ID(); ?>">
<h2>
<?php the_title(); ?>
</h2>
<div class="post-content">
<?php the_content(); ?>
</div>
<div class="entry">
<?php

// Generates the A-Z Jump Links
function getChars(){
$pages = get_pages();
$letters = array();
foreach( (array) $pages as $pg ){
$title = ucwords($pg->post_title);
$char = $title{0};
if( !(is_numeric($char)) && !in_array($char, $letters) ){
array_push($letters, $char);
}
}
return $letters;
}

echo '<ul class="letter-index">';
$anchors = getChars();
foreach( range('A', 'Z') as $char ){
if( in_array( $char, $anchors ) ){
echo '<li><a href="#'.$char.'-pages">'.$char.'</a></li>';
} else {
echo '<li><span>'.$char.'</span></li>';
}
}
echo '</ul><div class="clear"></div>';


$pages = get_pages(array('sort_order' => 'asc', 'sort_column' => 'post_title', 'hierarchical' => false));
$letters = array();
echo '<ul class="letter-directory">';
foreach( (array) $pages as $pg ){
$title = ucwords($pg->post_title);
$char = $title{0};
if( !( is_numeric($char) || empty($char) ) ){
if( $char != end($letters) && !empty($letters) ){
echo '</li></ul></div>';
}
if( !in_array($char, $letters) ){
echo '<div><ul class="letter-list-hold"><li id="'.$char.'-pages letter-box"><a name="'.$char.'-pages" class="anchor"/><span class="letter">'.$char.'</span><ul class="pages-ul">';
array_push($letters, $char);
}
echo "<li><a href='".get_page_link($pg->ID)."'>".$title."</a></li>";
}
}
echo '</ul>';
?>
</div>
</div>
<?php endwhile; endif; ?>
</div></div>
<?php include('inc/sidebar-if-active.php')?>
</div>
</div>
</div>
<?php get_footer(); ?>
<?php
/*
Template Name: A-Z Index
*/
get_header(); ?>
<?php include('inc/sidebar-check.php')?>

<div class="row">
<div class="span12">
<div class="row-fluid" id="primary">
<div class="span<?php echo (is_active_sidebar( $sidebar )?9:12); ?>">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post content clearfix" id="post-<?php the_ID(); ?>">
<h2>
<?php the_title(); ?>
</h2>
<div class="post-content">
<?php the_content(); ?>
</div>
<div class="entry">
<?php

// Generates the A-Z Jump Links
function getChars(){
$pages = get_pages();
$letters = array();
foreach( (array) $pages as $pg ){
$parent = is_parent_private($pg->ID);
if($parent !== false) $page = $parent;
else $page = $pg->ID;
$private = get_post_meta($page, 'uc-private', true);
if($private == 'admins' || $private == 'users' || $private == 'list'){
continue;
}
$title = ucwords($pg->post_title);
$char = $title{0};
if( !(is_numeric($char)) && !in_array($char, $letters) ){
array_push($letters, $char);
}
}
return $letters;
}

echo '<ul class="letter-index">';
$anchors = getChars();
foreach( range('A', 'Z') as $char ){
if( in_array( $char, $anchors ) ){
echo '<li><a href="#'.$char.'-pages">'.$char.'</a></li>';
} else {
echo '<li><span>'.$char.'</span></li>';
}
}
echo '</ul><div class="clear"></div>';


$pages = get_pages(array('sort_order' => 'asc', 'sort_column' => 'post_title', 'hierarchical' => false));
$letters = array();
echo '<ul class="letter-directory">';
foreach( (array) $pages as $pg ){
$parent = is_parent_private($pg->ID);
if($parent !== false) $page = $parent;
else $page = $pg->ID;
$private = get_post_meta($page, 'uc-private', true);
if($private == 'admins' || $private == 'users' || $private == 'list'){
continue;
}
$title = ucwords($pg->post_title);
$char = $title{0};
if( !( is_numeric($char) || empty($char) ) ){
if( $char != end($letters) && !empty($letters) ){
echo '</li></ul></div>';
}
if( !in_array($char, $letters) ){
echo '<div><ul class="letter-list-hold"><li id="'.$char.'-pages letter-box"><a name="'.$char.'-pages" class="anchor"/><span class="letter">'.$char.'</span><ul class="pages-ul">';
array_push($letters, $char);
}
echo "<li><a href='".get_page_link($pg->ID)."'>".$title."</a></li>";
}
}
echo '</ul>';
?>
</div>
</div>
<?php endwhile; endif; ?>
</div></div>
<?php include('inc/sidebar-if-active.php')?>
</div>
</div>
</div>
<?php get_footer(); ?>

0 comments on commit 70da853

Please sign in to comment.