Thanks- I just want to loop through a small number of pages, so $limit
works well. In one instance I know my page collection will be fixed- just three pages in that- but when I reuse this for another page collection, I know that number will vary widely so this variable works great.
One more thing- I want to display a header image to represent the pagination images for each page, along with the title. I have a header.svg
image under every page, so the name is the same regardless of page.
The idea is that both images and text are both represented for the user as they navigate from page to page. Here’s my code now:
<?php
$limit= $pages->find('services')->children()->count();
$subpages = $page->siblings()->paginate($limit);
$subpage = $page->sibling(self="true");
$image= $subpage->image('header.svg');
?><?php if($prev = $page->prevVisible()): ?>
<a class="prev" href="<?php echo $prev->url() ?>">← <img src="<?php echo $prev->$image->url();?><?php echo $prev->title()->html() ?></a>
<?php else: ?>
<a class="prev" href="<?php echo $subpages->last()->url() ?>">← <img src="<?php echo $subpages->last()->$image->url();?><?php echo $subpages->last()->title()->html() ?></a>
<?php endif ?>
<?php if($next = $page->nextVisible()): ?>
<a class="next" href="<?php echo $next->url() ?>"><img src="<?php echo $next->$image->url();?><?php echo $next->title()->html() ?> →</a>
<?php else: ?>
<a class="next" href="<?php echo $subpages->first()->url() ?>"><img src="<?php echo $subpages->first()->$image->url();?><?php echo $subpages->first()->title()->html() ?> →</a>
<?php endif ?>
Unfortunately, I seem not to be able to call the images. Ideas? Thanks again in advance for saving the day!