Get thubnail Attribute

Permalink 1 user found helpful
I will like to customize the default search block so i can have the result query with that page's thumbnail, that is a image custom attribute

View Replies:
jelthure replied on at Permalink Reply
easy, create a new page attribute. choose the "Image/File" type from the drop down, then call the new attribute: "Page Thumbnail" with a handle of "page_thumbnail".

The in the view file of the search block you can reference the image like this:
<div id="searchResults">
  <?php  foreach($results as $r) { 
  $f = File::getByID($r->getAttribute('page_thumbnail')); /* grabs the value of the current result/page attribute named page_thumbnail  */
  $ih = Loader::helper('image'); /* loads image helper */
  $max_width = 64; /*set to the width you want*/
  $max_height = 64; /*set to the height you want*/
  $currentPageBody = $this->controller->highlightedExtendedMarkup($r->getBodyContent(), $query);?>
  <div class="searchResult">
    <h3><a href="<?php echo $r->getPath()?>"><?php echo $r->getName()?></a></h3>
  <?php $ih->outputThumbnail($f, $max_width, $max_height); /* this outputs the image */ ?>
  <?php  echo ($currentPageBody ? $currentPageBody .'<br />' : '')?>
  <?php  echo $this->controller->highlightedMarkup($tt->shortText($r->getDescription()),$query)?>
  <span class="pageLink"><?php  echo $this->controller->highlightedMarkup($r->getPath(),$query)?></span>
rbnz replied on at Permalink Reply
I get:

Fatal error: Call to undefined method IndexedSearchResult::getAttribute()

I can get the ID for the result ( using $r->getID() )... but haven't worked out how to get the attribute for the result... I'm trying to get a list of tags for each result displayed.

Any suggestions? (php experience = 1 week)
rbnz replied on at Permalink Reply
found a bit of code here:

and modified it to this:

$ih = Loader::helper('image');
$oPage = Page::getById($r->getID()); //the ID of current result
$sTitle = $oPage->getCollectionName();
if($oThumb = $oPage->getAttribute('page_thumbnail')); 
//execute the following code if the thumbnail exists
<img src="<?php echo $ih->getThumbnail($oThumb, 100, 100)->src ?>" alt="<?php echo $title ?>" />

so far so good... next step - getting tags to display...