Page 1 of 1

Next / Previous pages

Posted: Sun Jan 12, 2020 9:48 pm
by bayerberg
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...

Re: Next / Previous pages

Posted: Fri Jan 31, 2020 12:44 am
by bayerberg
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?

Re: Next / Previous pages

Posted: Fri Jan 31, 2020 8:30 pm
by Edi
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?

Re: Next / Previous pages

Posted: Fri Jan 31, 2020 10:17 pm
by bayerberg
its not a timezone issue. time difference is around 20 minutes. it happens both on a local server and online.

Re: Next / Previous pages

Posted: Tue Feb 04, 2020 9:35 am
by diego
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?

Re: Next / Previous pages

Posted: Tue Feb 04, 2020 12:19 pm
by diego
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>';
	}
}
?>

Re: Next / Previous pages

Posted: Thu Feb 06, 2020 2:57 pm
by bayerberg
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.

Re: Next / Previous pages

Posted: Mon Feb 24, 2020 5:01 pm
by bayerberg
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.

Re: Next / Previous pages

Posted: Tue Feb 25, 2020 6:05 pm
by bayerberg
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!