Nothing should show up on the second project, but both lines on the first. The second project does not even have a next page!
thats pretty strange
What do you get in your navigation in the footer? Where does the first project link to, where the second?
Maybe thats the issueβ¦
The first project is linking to the next, if there is no next project it will link back to the first one:
<div class="project-next align">
<?php if($next = $page->nextVisible()): ?>
<a href="<?php echo $next->url() ?>">
<p>Next Project: <span><?php echo $next->title()?></span></p>
</a>
<?php else: ?>
<a href="<?php echo page('projects')->children()->first()->url() ?>">
<p>Next Project: <span><?php echo page('projects')->children()->first()->title()?></span></p>
</a>
<?php endif ?>
</div>
No, that code is absolutely fine, you want to link back to the first project if there is no next.
I meant the result: Does the first project actually link to the second project, and the second project to the first as desired?
yes, this is working without any problems
Letβs try something else then:
<?php
if($next = $page->nextVisible()) {
if($image = $next->images()->first()) {
echo thumb($image, array('width' => 300));
}
}
?>
It is shown up the same issue
Everything was correct as expected, only no thumb shown for the last project. Final solution:
<?php
if($next = $page->nextVisible()) {
if($image = $next->image('thumb.jpg')) {
echo thumb($image, array('width' => 300));
}
} else {
$first = $page->siblings()->first();
if($image = $first->image('thumb.jpg')) {
echo thumb($image, array('width' => 300));
}
}
?>
1 Like