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,73 +1,74 @@
<?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()) { ?>
<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-foot"></div>
<?php } endwhile; ?>
get_header();
if (have_posts()) {
the_post();
if (in_comic_category()) { ?>
<div id="comic-head"></div>
<div id="comic"><?php do_action('show_comic'); ?></div>
<div id="comic-foot"></div>
<?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 (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 the_time('F jS, Y') ?>
</div>
<?php if (get_option('comicpress-enable-storyline-support') == 1) { ?>
<ul class="storyline-cats"><li class="storyline-root"><?php the_category(' &raquo; </li><li>', 'multiple') ?></li></ul>
<?php } ?>
<h2><?php the_title() ?></h2>
<div class="entry">
<?php the_content() ?>
<?php the_transcript('styled') ?>
<div class="tags">
<?php the_tags('&#9492; Tags: ', ', ', ''); edit_post_link('Edit Post', ' [ ', ' ] ') ?>
</div>
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')) ?>
</div>
<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">
<div class="nav-blog-previous"><?php previous_post_link('%link','&lsaquo; Previous', TRUE) ?></div>
<div class="nav-blog-next"><?php next_post_link('%link','Next &rsaquo;', TRUE) ?></div>
</div>
<div class="clear"></div>
<h2><?php the_title() ?></h2>
<div class="postdate"><?php the_time('F jS, Y') ?></div>
<div class="entry">
<?php the_content() ?>
<?php the_transcript('styled') ?>
<div class="tags">
<?php the_tags('&#9492; Tags: ', ', ', ''); edit_post_link('Edit Post', ' [ ', ' ] ') ?>
</div>
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')) ?>
</div>
<br class="clear-margins" />
</div>
<div class="post-foot"></div>
<?php } ?>
<?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">
<?php include(dirname(__FILE__) . '/partials/nav.inc') ?>
<?php the_time('F jS, Y') ?>
</div>
<?php if (get_option('comicpress-enable-storyline-support') == 1) { ?>
<ul class="storyline-cats"><li class="storyline-root"><?php the_category(' &raquo; </li><li>', 'multiple') ?></li></ul>
<?php } ?>
<h2><?php the_title() ?></h2>
<div class="entry">
<?php the_content() ?>
<?php the_transcript('styled') ?>
<div class="tags">
<?php the_tags('&#9492; Tags: ', ', ', ''); edit_post_link('Edit Post', ' [ ', ' ] ') ?>
</div>
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')) ?>
</div>
<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">
<div class="nav-blog-previous"><?php previous_post_link('%link','&lsaquo; Previous', TRUE) ?></div>
<div class="nav-blog-next"><?php next_post_link('%link','Next &rsaquo;', TRUE) ?></div>
</div>
<div class="clear"></div>
<h2><?php the_title() ?></h2>
<div class="postdate"><?php the_time('F jS, Y') ?></div>
<div class="entry">
<?php the_content() ?>
<?php the_transcript('styled') ?>
<div class="tags">
<?php the_tags('&#9492; Tags: ', ', ', ''); edit_post_link('Edit Post', ' [ ', ' ] ') ?>
</div>
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')) ?>
</div>
<br class="clear-margins" />
</div>
<div class="post-foot"></div>
<?php } ?>
<?php comments_template() ?>
<?php endwhile; else: ?>
<?php comments_template() ?>
<?php }
} else { ?>
<div class="post-head"></div>
<div class="post">
@ -76,7 +77,7 @@
</div>
<div class="post-foot"></div>
<?php endif; ?>
<?php } ?>
</div>