Forums / General / Displaying custom class images - ezimagealiashandler
Michael Scott
Friday 20 April 2007 12:11:54 pm
Hi,
I've just started using Exponential (latest version) and am having trouble displaying images that I'm retrieving from a custom class.
It seems like it should be such a simple thing to do but I haven't been able to find a solution anywhere. Here's my code:
{def $winners=fetch( 'content', 'tree', hash( 'parent_node_id', 82, 'attribute_filter', $search_array ) )}
{foreach $winners as $w} {* display selection id *} {$w.object.contentobject_attributes[2].content[0]} {* display image....? Line below outputs "Object(ezimagealiashandler)" *} {$w.object.contentobject_attributes[6].content}{/foreach}
The code is retrieving my custom objects just fine but after searching for everything i can think of I still can't figure out how to display the image properly. Even the code to display a selection id seems unnecessarily complicated...surely there's an easier way to access an attribute (by name) ?
Would greatly appreciate any help anyone could give me.
Cheers,
Mike
Nabil Alimi
Friday 20 April 2007 12:42:59 pm
Hi Michael,
Simple. As expected. :)
You can use the <b>attribute_view_gui</b> operator.
{attribute_view_gui attribute=$w.object.contentobject_attributes[6] image_class=(small|large|original|*any-other-format-youve-defined)}
Besides, rather than
$w.object.contentobject_attributes[6]
you can use something like
$w.data_map.*attribute-identifier-of-the-attribute-you-wish-to-handle*
It will be much more easier to maintain and in case you change the orders of your attributes in your content class, you won't need to change your templates.
My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com eZ Publish Freelance developper. Feel free to contact me +33 674 367 057 nabil at assiki d0t fr
Friday 20 April 2007 12:50:37 pm
Exactly what i needed. Thanks for such a quick reply!