The title of the next and previous post

Post Reply
Gohh
Jr. Bludit
Posts: 2
Joined: Fri Aug 23, 2019 11:32 pm

Fri Aug 23, 2019 11:37 pm

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?
Gohh
Jr. Bludit
Posts: 2
Joined: Fri Aug 23, 2019 11:32 pm

Sun Aug 25, 2019 12:18 am

Is there a solution to my problem? :oops:
hxii
Jr. Bludit
Posts: 6
Joined: Sun Nov 22, 2015 11:01 am

Mon Aug 26, 2019 1:03 pm

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);
User avatar
diego
Site Admin
Posts: 703
Joined: Sat May 16, 2015 2:53 pm
Contact:

Mon Sep 16, 2019 10:45 am

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
Post Reply