Next / Previous pages

Post Reply
User avatar
bayerberg
Master Bludit
Posts: 141
Joined: Wed Jun 07, 2017 1:05 pm
Location: London, UK
Has thanked: 7 times
Been thanked: 10 times
Contact:

I'm doing next/ previous pages this way

Code: Select all

echo'<div class="row">';

	$previousPageKey = $page->previousKey();
	$previousPage = buildPage($previousPageKey);
	$nextPageKey = $page->nextKey();
	$nextPage = buildPage($nextPageKey);

	echo'<div class="six columns center-text">';
	echo '<p class="title">Next post: <br/>  ';
	if ($page->nextKey()) {
		echo'&#8729; <a href="'.$nextPage->permalink().'">'.$nextPage->title().'</a>';
		echo'<div class="hovering-button left"><a href="'.$nextPage->permalink().'" >&laquo;</a></div>';
	} else {
	echo 'Hold your horses, this is the latest post';
	}
	echo'</p>';
	echo'</div>';
	echo'<div class="six columns center-text">';
	echo '<p class="title">Previous post: <br/> &#8729; ';
	if ($page->previousKey()){
		echo'<a href="'.$previousPage->permalink().'">'.$previousPage->title().'</a>';
		echo'<div class="hovering-button right"><a href="'.$previousPage->permalink().'" >&raquo;</a></div>';
		} else {
		echo ' No more posts. You reached the end.';
	}
	echo'</p>';
	echo'</div>';
	
echo'</div>';
and sometimes I wont get either one. Whats the issue? Looks ok to me...
bludit plugins and themes - makeitblu | I do things, check them out on behance and dribbble.
User avatar
bayerberg
Master Bludit
Posts: 141
Joined: Wed Jun 07, 2017 1:05 pm
Location: London, UK
Has thanked: 7 times
Been thanked: 10 times
Contact:

Managed to track down the issue - it has to do something with a date and how its being set. Theres a time difference between my server and what Bludit sets on published posts. Any help?
bludit plugins and themes - makeitblu | I do things, check them out on behance and dribbble.
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

bayerberg wrote: Fri Jan 31, 2020 12:44 am Theres a time difference between my server and what Bludit sets on published posts.
What is the difference? What about setting another time zone in Bludit?
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
bayerberg
Master Bludit
Posts: 141
Joined: Wed Jun 07, 2017 1:05 pm
Location: London, UK
Has thanked: 7 times
Been thanked: 10 times
Contact:

its not a timezone issue. time difference is around 20 minutes. it happens both on a local server and online.
bludit plugins and themes - makeitblu | I do things, check them out on behance and dribbble.
User avatar
diego
Site Admin
Posts: 773
Joined: Sat May 16, 2015 2:53 pm
Been thanked: 1 time
Contact:

Hi,
maybe there is a bug on the function next and prev pages, I will check.
Have you tried to print the values or make a small example, I mean create 4 pages and check if the values returned is correct?
User avatar
diego
Site Admin
Posts: 773
Joined: Sat May 16, 2015 2:53 pm
Been thanked: 1 time
Contact:

I tried the functions and works fines.

Code: Select all

<?php
if ($WHERE_AM_I=='page') {
	if ($page->nextKey()) {
		$nextPage = buildPage($page->nextKey());
		echo "The title of the next page: ".$nextPage->title().'<br>';
	} else {
		echo "There is not next page.".'<br>';
	}
	
	if ($page->previousKey()) {
		$prevPage = buildPage($page->previousKey());
		echo "The title of the previous page: ".$prevPage->title().'<br>';
	} else {
		echo "There is not previous page.".'<br>';
	}
}
?>
User avatar
bayerberg
Master Bludit
Posts: 141
Joined: Wed Jun 07, 2017 1:05 pm
Location: London, UK
Has thanked: 7 times
Been thanked: 10 times
Contact:

thanks for checking. the bug is there somewhere :) i get the issue quite often, dont have a clue why it happens though. ill post up the example when it happens.
bludit plugins and themes - makeitblu | I do things, check them out on behance and dribbble.
User avatar
bayerberg
Master Bludit
Posts: 141
Joined: Wed Jun 07, 2017 1:05 pm
Location: London, UK
Has thanked: 7 times
Been thanked: 10 times
Contact:

diego wrote: Tue Feb 04, 2020 12:19 pm I tried the functions and works fines.
@diego ha! happened again - https://dontbe.soy/
json looks ok but the site mangles previous/ next pages. first one doesn't have any, then next two sit together and then the rest of the page works as normal. there might be a wonky loop somewhere, trying to find it.
bludit plugins and themes - makeitblu | I do things, check them out on behance and dribbble.
User avatar
bayerberg
Master Bludit
Posts: 141
Joined: Wed Jun 07, 2017 1:05 pm
Location: London, UK
Has thanked: 7 times
Been thanked: 10 times
Contact:

ha! looks like page type might have something to do with it - had a bunch of drafts and when I deleted them everything went back to normal!
bludit plugins and themes - makeitblu | I do things, check them out on behance and dribbble.
haywardgg
Ssr. Bludit
Posts: 19
Joined: Wed Apr 05, 2023 10:46 pm
Has thanked: 4 times
Been thanked: 1 time

bayerberg wrote: Tue Feb 25, 2020 6:05 pm ha! looks like page type might have something to do with it - had a bunch of drafts and when I deleted them everything went back to normal!
Did you ever get this working reliably ?

For me it's random. I'll post several pages and they all work fine , the next and previous links work as expected. But I'll edit a page or change the post date or something and the next or previous link for that page will break, even though there's pages both sides in the cue. I can sometimes fix it by changing the date of the post to a few days in the past, but then that defeats the object of a blog imho.

The code I'm using for the next and previous links. https://gist.github.com/haywardgb/47118 ... bec31fe5a5

Any ideas ? I've not got any drafts and like I said it works one minute then for no apparent reason the next page will break the links.. No erros in the logs or debug!
Post Reply