I am a bit confused about how to build the navigation through my website, due to my poor PHP skills. Maybe someone could help me with this.
Background is this: My website is like a scrap book or a collection of unordered pages. Let’s say I found a bunch of loose papers and I bind them into a book, one after another. Later I detect that they all belong to different projects, and I put them into an order in an index. Maybe I want to list them in one of those index folders later. But the order of pages in the book must remain the same.
I have a page structure like that (my „index"), with certain time stamps:
Home
The sea/
The guests vanish, date 09.01.2014/
At the platform, date 06.04.2014/
A ship arrives, date 03.07.2015/
The land suveyor/
Flora and fauna, date 07.03.2014/
Deepest cellar, date 05.05.2015/
The burning exit, date 01.09.2016/
The fourteen Holy Helpers/
Vitus, date 08.02.2014/
Barbara, date 04.06.2015/
Christoph, date 02.08.2016/
About
Contact
This structure is mirrored in the menu navigation, as sort of an index.
My intention is
-
to show ALL the pages, one after another, irrespective of their category („The sea“, "The land surveyor“, "The fourteen Holy Helpers“), ordered by their time stamp, with the newest published page on/as the home page (a flipped page order).
-
But if I navigate to the category, I want to display each page of only this category in chronological order, with the oldest as starting point.
-
So the unordered page order would be:
„The burning exit“ (home page) -> „Christoph“ -> „A ship arrives“ -> „Barbara“ -> „The deepest cellar“, and so on. -
The category page order would be like in my index, but only one category.
The home page is like this:
<?php $article = $site->index()->visible()->sortBy('date', 'desc')->first() ?>
<article>
<div><?php echo $article->parent()->title()->html() ?></div>
<div><?php echo $article->date('d. m. Y') ?></div>
<h1><?php echo html($article->title()) ?></h1>
<?php echo $article->text()->kirbytext() ?>
</article>
But how do I set up the page navigation? I guess it must be two setups, with an if-expression, one of those being
<nav role="navigation">
<?php if($prev = $page->prevVisible()): ?>
<a href="<?php echo $prev->url() ?>">← previous</a>
<?php endif ?>
<?php if($next = $page->nextVisible()): ?>
<a href="<?php echo $next->url() ?>">next →</a>
<?php endif ?>
</nav>
Could someone help me with this if-expression and the alternative navigation?