Permalink
Browse files

adds next/prev link vars

  • Loading branch information...
jackmcdade committed Mar 30, 2012
1 parent 6f586d3 commit 0cfc034106c6959698a9651d2ffbf1ab0497986e
Showing with 26 additions and 12 deletions.
  1. +5 −1 content/20120327/index.php
  2. +5 −1 content/20120329/index.php
  3. +5 −1 content/20120330/index.php
  4. +11 −9 index.php
@@ -1,2 +1,6 @@
<h1><?= $title ?></h1>
<h6>May 27th.</h6>
<h6>May 27th.</h6>
<ul>
<? if ($prev): ?><li><a href="<?= $prev ?>">Previous</a></li><? endif ?>
<? if ($next): ?><li><a href="<?= $next ?>">Next</a></li><? endif ?>
</ul>
@@ -1,2 +1,6 @@
<h1><?= $title ?></h1>
May 29th.
<h6>May 29th.</h6>
<ul>
<? if ($prev): ?><li><a href="<?= $prev ?>">Previous</a></li><? endif ?>
<? if ($next): ?><li><a href="<?= $next ?>">Next</a></li><? endif ?>
</ul>
@@ -1,2 +1,6 @@
<h1><?= $title ?></h1>
May 30th.
<h6>May 30th.</h6>
<ul>
<? if ($prev): ?><li><a href="<?= $prev ?>">Previous</a></li><? endif ?>
<? if ($next): ?><li><a href="<?= $next ?>">Next</a></li><? endif ?>
</ul>
View
@@ -46,8 +46,12 @@ function get_directories()
{
$dirs = array_filter(glob('content/*', GLOB_ONLYDIR), 'is_dir');
array_walk($dirs, function(&$item, $key) {
$item = get_endpoint($item);
});
// remove the archive dir
$archive = array_search('content/archive', $dirs);
$archive = array_search('archive', $dirs);
if ($archive)
unset($dirs[$archive]);
@@ -59,15 +63,15 @@ function find_latest()
$dirs = get_directories();
$latest = end($dirs);
return get_dir_endpoint($latest);
return get_endpoint($latest);
}
function find_next($date)
{
$dirs = get_directories();
$current = array_search('content/'.$date, $dirs);
$current = array_search($date, $dirs);
if ($current)
if ($current !== FALSE)
{
while (key($dirs) !== $current) next($dirs);
return next($dirs);
@@ -79,8 +83,8 @@ function find_next($date)
function find_prev($date)
{
$dirs = get_directories();
$current = array_search('content/'.$date, $dirs);
if ($current)
$current = array_search($date, $dirs);
if ($current !== FALSE)
{
while (key($dirs) !== $current) next($dirs);
return prev($dirs);
@@ -89,7 +93,7 @@ function find_prev($date)
return FALSE;
}
function get_dir_endpoint($dir)
function get_endpoint($dir)
{
$dir_array = explode('/', $dir);
return end($dir_array);
@@ -115,8 +119,6 @@ function get_dir_endpoint($dir)
$data = get_meta($date);
print_r($data);
$app->render($date.'/index.php', $data);
});

0 comments on commit 0cfc034

Please sign in to comment.