Hi folks,
I'm set up a simple next/prev between pages that are loaded in via pjax with the following:
<?php if ($page->next->id) : ?>
<div class="next-solution-container">
<a data-pjax class="next-solution" href="<?php echo $page->next->url; ?>"><span><?php echo $page->next->title; ?></span></a>
</div>
<?php endif; ?>
This worked great, but I want it now to loop... so if it's the last item, it gets the first item as the next link. I thought the following below would work, but as I am using it on the page template, and thus using $page, I don't think first/last are in use?
<?php if ($page == $page->last) : ?>
<div class="next-solution-container">
<a data-pjax class="next-solution" href="<?php echo $page->first->url; ?>"><span><?php echo $page->first->title; ?></span></a>
</div>
<?php else : ?>
<div class="next-solution-container">
<a data-pjax class="next-solution" href="<?php echo $page->next->url; ?>"><span><?php echo $page->next->title; ?></span></a>
</div>
<?php endif; ?>
Any thoughts?