How to get attribute of the Next/Prev page

Permalink
In blog_entry i added the "prev-next" block.

I want to create this famous "next-prev" layout (see screen shot)

[thumb] NEXT>
[thumb] <PREV

I have the link of next/prev and page names from the core block. And the design its only CSS and a little markup.

"THE PROBLEM" - i dont know how to get the thumbnail attribute of the "next" of "prev" pages (in other world how to get the correct page object)

1 Attachment

siton
 
hutman replied on at Permalink Reply
hutman
Are you creating a custom template for the Prev/Next block or are you creating your own custom block with similar functionality?
siton replied on at Permalink Reply
siton
Similar. Custom template. I only want to change the markup
MrKDilkington replied on at Permalink Best Answer Reply 1 Attachment
MrKDilkington
Hi siton,

I have attached a custom template for the Next & Previous block that will get the thumbnail attribute of next and previous pages. The same approach can be used to get the page description and other attributes and page information.
siton replied on at Permalink Reply
siton
Where i can find a code example?....thanks
MrKDilkington replied on at Permalink Reply
MrKDilkington
@siton

You can find the code example attached to my previous reply.
siton replied on at Permalink Reply
siton
Thanks it really help me. In PHP i always get error
"syntax error, unexpected 'echo' (T_ECHO), expecting ',' or ';' "

For example i want to add to your code "alt" - what wrong with this code? (look at end of the code).

Thanks

<?php
$previousThumbnailAttribute = $previousCollection->      getCollectionAttributeValue('thumbnail');
$alt = $previousThumbnailAttribute->getDescription(); 
   if (is_object($previousThumbnailAttribute)) {
      $previousThumbnail = $ih->getThumbnail($previousThumbnailAttribute, 80, 80, true);
      echo '<img class="class="uk-thumbnail"" src= "' . $previousThumbnail->src . 
      '" width="' . $previousThumbnail->width . 
      '" height="'. $previousThumbnail->height .
          /*error line */
   '" alt="' echo $alt '">'; //this line makes the error
      }
   ?>
WebcentricLtd replied on at Permalink Reply
you are already echoing the output so you should change that last line to:

'" alt="' .$alt. '">';

rather than using echo again
stewblack23 replied on at Permalink Reply
stewblack23
If anyone needs this. I have updated the custom template that MrKDilkington so kindly created. You can use this in version 8 and up.

<?php
defined('C5_EXECUTE') or die("Access Denied.");
if (!$previousLinkURL && !$nextLinkURL && !$parentLabel) {
    return false;
}
if (is_object($nextCollection)) {
  $nextThumbnailAttribute = $nextCollection->getCollectionAttributeValue('thumbnail');
  $imageNext = \Core::make('html/image', array($nextThumbnailAttribute));
  $nextImg = $imageNext->getTag();
}
?>
//Add this part to the specific area you need the thumbnail to display. 
<?php if ($nextImg) { ?>
        <div class="ccm-next-thumbnail">
          <?php echo '<a href="' . $nextLinkURL . '">' . $nextImg . '</a>'; ?>