nav fixed

This commit is contained in:
John Bintz 2009-07-12 19:31:47 -04:00
parent 133f419e84
commit 4a15725d3f
5 changed files with 82 additions and 144 deletions

View File

@ -174,14 +174,17 @@ class ComicPress {
}
function get_nav_comics() {
global $post;
$comic_posts = array();
foreach (array('first', 'last', 'previous', 'next') as $which) {
$comic_posts[$which] = $this->{"get_${which}_comic"}();
}
$comic_posts['show_first'] = ($comic_posts['first']->ID !== $comic_posts['last']->ID);
$comic_posts['show_previous'] = (!empty($comic_posts['previous']) && ($comic_posts['first']->ID !== $comic_posts['previous']->ID));
$comic_posts['show_next'] = (!empty($comic_posts['next']) && ($comic_posts['last']->ID !== $comic_posts['next']->ID));
$comic_posts['show_first'] = ($comic_posts['first']->ID != $comic_posts['last']->ID);
$comic_posts['show_previous'] = (!empty($comic_posts['previous']) && ($comic_posts['first']->ID != $comic_posts['previous']->ID));
$comic_posts['show_next'] = (!empty($comic_posts['next']) && ($comic_posts['last']->ID != $comic_posts['next']->ID));
$comic_posts['show_last'] = (trim($post->ID) != trim($comic_posts['last']->ID));
return $comic_posts;
}

View File

@ -75,61 +75,12 @@ function __comicpress_init() {
}
}
}
//get_all_comic_categories();
}
function the_comic_img_tag($url, $type, $additional_parameters = array()) {
global $comicpress;
function in_comic_category() {
global $post, $comicpress;
echo $comicpress->get_comic_img_tag($url, $type, $additional_parameters);
}
/**
* Get the hyperlink to the first comic post in the database.
* @return string The hyperlink to the first comic post, or false.
*/
function get_first_comic_permalink() {
global $comicpress;
$terminal = $comicpress->get_first_comic();
return !empty($terminal) ? get_permalink($terminal->ID) : false;
}
/**
* Get the hyperlink to the last comic post in the database.
* @return string The hyperlink to the first comic post, or false.
*/
function get_last_comic_permalink() {
global $comicpress;
$terminal = $comicpress->get_last_comic();
return !empty($terminal) ? get_permalink($terminal->ID) : false;
}
/**
* Get the link to the previous comic from the current one.
*/
function previous_comic_link($format, $link) {
global $non_comic_categories;
previous_post_link($format, $link, false, $non_comic_categories);
}
/**
* Get the link to the next comic from the current one.
*/
function next_comic_link($format, $link) {
global $non_comic_categories;
next_post_link($format, $link, false, $non_comic_categories);
}
/**
* Get the adjacent comic from the current one.
* @param int $category The category to use.
* @param boolean $next True if the next chronological comic should be retrieved.
* @return array The WordPress post object for the comic post.
*/
function get_adjacent_comic($category, $next = false) {
return $comicpress->in_comic_category($post->ID);
}
/**

View File

@ -42,6 +42,4 @@
</ul>
<div class="clear"></div>
</div>

View File

@ -2,6 +2,9 @@
global $comicpress;
get_header();
$nav_comics = $comicpress->get_nav_comics();
$post = $nav_comics['last'];
?>
<?php if (!is_paged()) { ?>
@ -12,28 +15,10 @@
<div id="content" class="narrowcolumn">
<?php if (!is_paged()) {
$nav_comics = $comicpress->get_nav_comics();
$post = $nav_comics['last'];
?>
<?php if (!is_paged()) { ?>
<div class="post-comic-head"></div>
<div class="post-comic">
<div class="nav">
<?php if ($nav_comics['show_first']) { ?>
<div class="nav-first">
<a href="<?php echo get_permalink($nav_comics['first']->ID) ?>"
title="<?php _e('Go to the first comic', 'comicpress') ?>">&lsaquo;&lsaquo; First</a>
</div>
<?php } ?>
<?php if ($nav_comics['show_previous']) { ?>
<div class="nav-previous">
<a href="<?php echo get_permalink($nav_comics['previous']->ID) ?>"
title="<?php _e('Go to the previous comic', 'comicpress') ?>">&lsaquo; Previous</a>
</div>
<?php } ?>
</div>
<?php include(dirname(__FILE__) . '/partials/nav.inc') ?>
<div class="comicdate">
<?php the_date('F jS, Y') ?>
</div>

View File

@ -1,27 +1,29 @@
<?php get_header(); $first_comic = get_first_comic_permalink(); $last_comic = get_last_comic_permalink() ?>
<?php
global $comicpress;
<?php while (have_posts()) : the_post(); if (in_comic_category()) { ?>
get_header();
if (have_posts()) {
the_post();
if (in_comic_category()) { ?>
<div id="comic-head"></div>
<div id="comic">
<img src="<?php the_comic() ?>" alt="<?php the_title() ?>" title="<?php the_hovertext() ?>" />
</div>
<div id="comic"><?php do_action('show_comic'); ?></div>
<div id="comic-foot"></div>
<?php } endwhile; ?>
<?php }
}
rewind_posts();
$nav_comics = $comicpress->get_nav_comics();
?>
<div id="content" class="narrowcolumn">
<?php if (have_posts()) : while (have_posts()) : the_post() ?>
<?php if (have_posts()) { ?>
<?php while (have_posts()) { the_post() ?>
<?php if (in_comic_category()) { ?>
<div class="post-comic-head"></div>
<div class="post-comic" id="post-<?php the_ID() ?>">
<div class="comicdate">
<div class="nav">
<?php if ( get_permalink() != $first_comic ) { ?><div class="nav-first"><a href="<?php echo $first_comic ?>">&lsaquo;&lsaquo; First</a></div><?php } ?>
<div class="nav-previous"><?php previous_comic_link('%link', '&lsaquo; Previous') ?></div>
<div class="nav-next"><?php next_comic_link('%link', 'Next &rsaquo;') ?></div>
<?php if ( get_permalink() != $last_comic ) { ?><div class="nav-last"><a href="<?php echo $last_comic ?>">Last &rsaquo;&rsaquo;</a></div><?php } ?>
</div>
<?php include(dirname(__FILE__) . '/partials/nav.inc') ?>
<?php the_time('F jS, Y') ?>
</div>
<?php if (get_option('comicpress-enable-storyline-support') == 1) { ?>
@ -39,9 +41,7 @@
<br class="clear-margins" />
</div>
<div class="post-comic-foot"></div>
<?php } else { ?>
<div class="post-head"></div>
<div class="post" id="post-<?php the_ID() ?>">
<div class="nav-blog">
@ -67,7 +67,8 @@
<?php comments_template() ?>
<?php endwhile; else: ?>
<?php }
} else { ?>
<div class="post-head"></div>
<div class="post">
@ -76,7 +77,7 @@
</div>
<div class="post-foot"></div>
<?php endif; ?>
<?php } ?>
</div>