Context:
I posted on the old forums asking about customising the Express List Block to make it so that the “Image” Attribute type of an Express Entry shows the image graphic itself, instead of the hyperlink to the image file (which is not useful lol). Original thread here : Stuck on making template for Express List Block - Showing images - concrete5
@mnakalay was helping me in that thread.
I’m starting this thread to continue it.
Firstl, the code snipping that @mnakalay posted at the end worked for me so far! I need to tune it more as I think my own work has broken the processing of the rest of the columns after the image file, plus there’s a typo in the code that @mnakalay posted. The “” part has one too many closing brackets and instead should be “
”
That being said, yay! Thanks @mnakalay !
I may continue to seek help in this thread with what I’m trying to do here, but right now it looks to work for me
Sorry that it took so long for me to test it, one month + one day to the day, life has been a bit chaotic. But @mnakalay 's help is very much appreciated! Hopefully this can help others too. Here’s the original code-block posted from them (with the correction). This is for the view.php, starting at line 98 in the original unmodified view.php file, for those that want to implement it in the future:
<?php
$entry = $item->getEntry();
foreach ($item->getColumns() as $column) {
$columnKey = $column->getColumnKey(); // ak_some_attribute_handle
$attrHandle = substr($columnKey, 3); // remove the ak_ to get the attribute's handle
$category = $entity->getAttributeKeyCategory(); // get the attribute category (here it's Express)
$attribute = $category->getAttributeKeyByHandle($attrHandle); // get the attribute object now that we have its handle and its category
// some columns are not for attributes but for other objects like associations or default fields so make sure you do have an attribute before getting its type
if ($attribute && is_object($attribute)) {
$attrTypeHandle = $attribute->getAttributeTypeHandle();
if ($attrTypeHandle == 'image_file') {
$fv = $entry->getAttribute($attribute);
if (is_object($fv)) {
?>
<td><img src="<?=$fv->getURL()?>"></td>
<?php
}
}
}
} // end foreach item->getColumns