From 48b6a3867e9691b28f5e932c68e198527f403506 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Thu, 17 Feb 2011 18:37:18 +1100 Subject: [PATCH] prev/next page buttons --- inc/functions.php | 37 +++++++++++++++++++++++++++++++++++++ mod.php | 1 + templates/index.html | 4 ++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index c5b8f9b6..eccdc4ee 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -469,6 +469,42 @@ return Array('button'=>$config['button_newtopic'], 'board'=>$board, 'body'=>$body, 'post_url' => $config['post_url'], 'index' => $config['root']); } + function getPageButtons($pages, $mod=false) { + global $config, $board; + + $btn = Array(); + $root = ($mod ? '?/' : $config['root']) . $board['dir']; + + foreach($pages as $num => $page) { + if(isset($page['selected'])) { + // Previous button + if($num == 0) { + // There is no previous page. + $btn['prev'] = 'Previous'; + } else { + $btn['prev'] = '
'; + } + + if($num == count($pages) - 1) { + // There is no next page. + $btn['next'] = 'Next'; + } else { + $btn['next'] = '
'; + } + } + } + + return $btn; + } + function getPages($mod=false) { global $board, $config; @@ -601,6 +637,7 @@ $content['pages'] = $pages; $content['pages'][$page-1]['selected'] = true; + $content['btn'] = getPageButtons($content['pages']); @file_put_contents($filename, Element('index.html', $content)) or error("Couldn't write to file."); if(isset($md5) && $md5 == md5_file($filename)) { diff --git a/mod.php b/mod.php index 66b7cdef..fb997e4c 100644 --- a/mod.php +++ b/mod.php @@ -326,6 +326,7 @@ $page['pages'] = getPages(true); $page['pages'][$page_no-1]['selected'] = true; + $page['btn'] = getPageButtons($page['pages'], true); $page['mod'] = true; echo Element('index.html', $page); diff --git a/templates/index.html b/templates/index.html index 3548eeef..10973671 100644 --- a/templates/index.html +++ b/templates/index.html @@ -102,9 +102,9 @@ -
Pages: {pages: +
{btn[prev]} {pages: [{pages[num]}]{!%last? } - }
+ } {btn[next]}

Tinyboard Software Copyright © 2010-2011 OmegaSDG

\ No newline at end of file