Custom template Express List?

Permalink
Hi C5'ers!

I'm getting into the new express, really love it!!
I'm trying to display an express list with a custom template, but how do I output my custom attribute values individually, instead of displaying all values of the item? Is there something just like the getBoats method on Andrew's example? Below stripped list template:

<?php defined('C5_EXECUTE') or die(_("Access Denied."));
$c = Page::getCurrentPage();
if ($entity) {
   $results = $result->getItemListObject()->getResults();
   if (count($results)) {
      foreach($result->getItems() as $item) {
         foreach($item->getColumns() as $column) {    
            // echo $column->getColumnValue($item);
            // How do I echo attribute name? getMyAttributeHandle?
            // How do I echo attribute image?
         }
      }
   } else {
      echo t('No "%s" entries can be found', $entity->getName());
   }


Many thanks,
Nick

nickratering
 
chasePeta replied on at Permalink Best Answer Reply
Inside the loop of $result->getItems() as $item you can use the getEntry() on the $item and store that to a variable to use the get[AttributeName]() on the variable.
Kiesel replied on at Permalink Reply
The get[AttributeName]() ? Could you elaborate that?

Nevermind, got it: $blah->getSurname() and so on.
nickratering replied on at Permalink Reply
nickratering
A bit too late, but thank you very much!!!!!!

echo $item->getEntry()->getSurname();
ngaffer replied on at Permalink Reply
ngaffer
How do I do this with an image that is stored in the file manager? If I use the code you suggested
<?php echo $item->getEntry()->getProductImage(); ?>
I get this error: "Object of class DoctrineProxies\__CG__\Concrete\Core\Entity\File\File could not be converted to string"
ngaffer replied on at Permalink Reply
ngaffer
I figured this out.
<?php echo $item->getEntry()->getProductImage()->getUrl(); ?>
nickratering replied on at Permalink Reply
nickratering
You can also resize the image:

$productThumbnail = $item->getEntry()->getProductImage();
if ($productThumbnail) {
   if ($productThumbnail_thumb = Core::make('helper/image')->getThumbnail($productThumbnail, 250, 250, true)) { // square 250x250, cropped
      $imgsrc = $productThumbnail_thumb->src;
   }
}
echo '<img src="' . $imgsrc . '">';
lukrecija replied on at Permalink Reply 1 Attachment
Any insights on how would you call the Associated Object in the same list?