Ouch!Working on my home page redesign recently, I wanted to have a link to the previous and next entries at the bottom of each entry page. I spent a couple of hours creating a PHP script that recursively scanned the archives folders and built an array of all the pages beginning with the words "entry_" and sorts them by entry id, and then another script within the entry template:
<?php
$entry_link = "<$EntryPermalink$>";
$key = array_search($entry_link, $file_listing);
$prev_key = $key - 1;
$next_key = $key + 1;
if (!empty($file_listing[$prev_key])) {
echo "| <a href=\"$file_listing[$prev_key]\" title=\"Previous Page\">Previous Page</a>";
}
if (!empty($file_listing[$next_key])) {
echo "| <a href=\"$file_listing[$next_key]\" title=\"Next Page\">Next Page</a>";
}
echo "<br />\r\n";
?>
that searches the array for the next (higher) and previous (lower) value to come up with the next/previous page links.
One problem I encountered was that my entry IDs are not in order with the date. So my entry IDs actually look like 2, 3, 5, 4, 6. To fix this I would have had to rewrite the script to sort by file date, or go into the database directly and create q uery that re-orders my entry IDs.
Oh if only I had bothered to reread the help file. I found this:
<NextPage>
<IfPageExists>| <!--<$PageName$>--><a href="<$PageLink$>" title="Previous Page">Previous Page</a></IfPageExists>
<IfNoPageExists></IfNoPageExists>
</NextPage>
<PreviousPage>
<IfPageExists>| <!--<$PageName$>--><a href="<$PageLink$>" title="Next Page">Next Page</a></IfPageExists>
<IfNoPageExists></IfNoPageExists>
</PreviousPage>
It's way easier to set up plus it has the advantage of determining order by post date instead of entry ID.
It now occurs to me that I should reread the help file AGAIN and create a features checklist that I could run through every time I create a new blog - that details all of the built-in features of TAMB - before I go needlessly "extending" feature/functionality agian...