Peter Knight Posted January 12, 2016 Share Posted January 12, 2016 Hi I have a series of child pages with Next and Back thumbnails under each page. Parent - Child 1 - Child 2 - Child 3 - Child 4 I want Child page 1 to know it's the first page and not try to render a thumbnail. Likewise, I want Child page 4 to know it's the last page etc... My code works when I am not trying to call a thumbnail but as soon as I try to check for the existence of a previous or next page, my check fails. <figure class="uk-overlay"> <?php //get the cropped thumbnail from the previous page $image = $page->prev->Images->first()->getCrop('articlesquare'); // if there is a previous page, show a thumbnail if($page->prev){ echo "<img src='{$image->url}' alt='{$image->description}' class='art-prev' />"; } else { echo "";} ?> <div class="uk-overlay-panel uk-overlay-chevron-left"></div> </figure> <a class="<?=$page->prev->id ? 'previous' : 'no-before'?>" href="<?php echo $page->prev->path; ?>"><?=$page->prev->title?></a> Should I in fact be approaching this differently as the page is first looking for the existence of a cropped thumbnail? Link to comment Share on other sites More sharing options...
Peter Knight Posted January 12, 2016 Author Share Posted January 12, 2016 Solved with the help of Tom's question in 2012 I adapted it slightly to <?php if ($page->prev->id) { $prevThumb = $page->prev()->Images->first()->getCrop('articlesquare'); echo " <h3>Previous Article</h3> <figure class='uk-overlay'> <img src='{$prevThumb->url}' /> <div class='uk-overlay-panel uk-overlay-chevron-left'></div> </figure> <a href='{$page->prev->url}'>{$page->prev->title}</a> ";} ?> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now