Page 1 of 1

The title of the next and previous post

Posted: Fri Aug 23, 2019 11:37 pm
by Gohh
Hi, I use to post links to the next and previous post:

Code: Select all

<?php echo Theme::siteUrl() . $page->previousKey(); ?>
<?php echo Theme::siteUrl() . $page->nextKey(); ?>
But how to deduce the title of the posts?

Re: The title of the next and previous post

Posted: Sun Aug 25, 2019 12:18 am
by Gohh
Is there a solution to my problem? :oops:

Re: The title of the next and previous post

Posted: Mon Aug 26, 2019 1:03 pm
by hxii
I guess you can use something like (after, obviously, writing the code more normally)

Code: Select all

$pre_page = $page->previousKey();
$next_page = $page->nextKey();

$page_handler = new Pages();
$pre_page_title = $page_handler->getPageDB($pre_page);
$next_page_title = $page_handler->getPageDB($next_page);

Re: The title of the next and previous post

Posted: Mon Sep 16, 2019 10:45 am
by diego
You can do something like this.

Code: Select all

$pageKey = $page->previousKey();
$page = buildPage($pageKey);
echo $page->title();
https://docs.bludit.com/en/dev-snippets/content-pages

Re: The title of the next and previous post

Posted: Thu Sep 19, 2019 2:34 pm
by bayerberg
this is a cool feature but needs a bit of tweaking. if you run a normal blog it works fine, but if you rely on categories and need to display next page in the category theres a need for a bit of code jiggery. would be great if this could be configurable in settings or with extra variable.

Re: The title of the next and previous post

Posted: Wed Apr 08, 2020 11:21 pm
by Gohh
I have a problem. The previous post is running, the next one shows the current post.

Code: Select all

<?php $prevPage = $page->previousKey();
$page = buildPage($prevPage);
echo ' <a href="' . $page->permalink() . '">' . $page->title() . '</a> '; ?>

<?php $nextPage = $page->nextKey();
$page = buildPage($nextPage);
echo ' <a href="' . $page->permalink() . '">' . $page->title() . '</a> '; ?>