Displaying custom class images - ezimagealiashandler

Author Message

Michael Scott

Friday 20 April 2007 12:11:54 pm

Hi,

I've just started using eZ publish (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

Michael Scott

Friday 20 April 2007 12:50:37 pm

Exactly what i needed. Thanks for such a quick reply!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 04:23:16
Script start
Timing: Jan 31 2025 04:23:16
Module start 'layout'
Timing: Jan 31 2025 04:23:16
Module start 'content'
Timing: Jan 31 2025 04:23:16
Module end 'content'
Timing: Jan 31 2025 04:23:16
Script end

Main resources:

Total runtime0.0168 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.2578151.2266
Module start 'layout' 0.00500.0028 739.484436.6797
Module start 'content' 0.00780.0074 776.164190.2813
Module end 'content' 0.01520.0016 866.445333.9922
Script end 0.0168  900.4375 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002514.8936140.0002
Check MTime0.00116.7475140.0001
Mysql Total
Database connection0.00084.674410.0008
Mysqli_queries0.002213.054830.0007
Looping result0.00000.119310.0000
Template Total0.00127.010.0012
Template load0.00095.228210.0009
Template processing0.00031.713910.0003
Override
Cache load0.00063.697510.0006
General
dbfile0.003017.932380.0004
String conversion0.00000.058240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs