Overriding how an object name looks?

Author Message

eric l

Thursday 13 October 2005 6:52:57 pm

So this is only day two using ezpublish for me, so I apologize if my terminology is a little off.

I'm trying to set up recipes on my site, right now I have the following content classes:

Ingredient_Measure [Float, String] (Example: 0.5, Cup)
Ingredient_Type [String] (Example: Flour)
Ingredient [Ingredient_Measure, Ingredient_Type] (Example: 0.5 Cup Flour)

and Recipe, which has a variety of stuff but contains an ObjectRelations of Ingredients.

I made an override for node/view/full.tpl for the Recipe class, and I have it getting the content out of the $node mostly as expected. I'm using the attribute_view_gui call to display the ingredient list, which leads to a list of the ingredients with links to the nodes for those ingredients. But the names of the ingredients are as you would expect "0.50 Cup Flour" what I would like to do is override how that name is computed in order to display "1/2 Cup Flour"

How would I go about doing that? Or I suppose more to the point: Where is that name computed from the Ingredient class? As that is what I need to override.

Thanks!

eric l

Friday 14 October 2005 1:08:13 pm

To answer my own question...

When using attribute_view_gui to show an Object Relations list you can control how each of the objects being displayed in the list by overriding the /content/view/embed.tpl template for each Object Class in the relations list you want to change.

In my case I made:

design/plain/override/templates/ingredient_embed.tpl

which shows the amount of the ingredient in more normal recipe format of displaying fractions. (Anyone know if there is a handy function to get a fraction from a float so that I don't have to use that switch?)

------
{* Embedded Ingredient *}

{def $amount = $object.data_map.measure.content.data_map.amount.data_float}
{switch match=$amount}

{case match=0.125}
1/8
{/case}

{case match=0.25}
1/4
{/case}

{case match=0.5}
1/2
{/case}

{case match=0.75}
3/4
{/case}

{case match=1}
1
{/case}

{* Default to just showing the float. *}
{case}
{attribute_view_gui attribute=$object.data_map.measure.content.data_map.amount}
{/case}

{/switch}

{attribute_view_gui attribute=$object.data_map.measure.content.data_map.measure}

{* TODO change this to link to a list of all recipes using this type.*}
{attribute_view_gui attribute=$object.data_map.type.content.data_map.type}
------

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 18 2025 22:28:18
Script start
Timing: Jan 18 2025 22:28:18
Module start 'layout'
Timing: Jan 18 2025 22:28:18
Module start 'content'
Timing: Jan 18 2025 22:28:19
Module end 'content'
Timing: Jan 18 2025 22:28:19
Script end

Main resources:

Total runtime0.7040 sec
Peak memory usage4,096.0000 KB
Database Queries52

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 588.0313152.6406
Module start 'layout' 0.00480.0028 740.671939.4609
Module start 'content' 0.00760.6951 780.1328437.1641
Module end 'content' 0.70270.0013 1,217.29698.1563
Script end 0.7040  1,225.4531 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.4446160.0002
Check MTime0.00140.1942160.0001
Mysql Total
Database connection0.00060.088510.0006
Mysqli_queries0.658393.4999520.0127
Looping result0.00040.0535500.0000
Template Total0.678396.320.3392
Template load0.00230.326320.0011
Template processing0.676096.021620.3380
Template load and register function0.00020.024110.0002
states
state_id_array0.00080.109210.0008
state_identifier_array0.00070.095120.0003
Override
Cache load0.00190.2744490.0000
Sytem overhead
Fetch class attribute can translate value0.00060.079210.0006
Fetch class attribute name0.00090.126420.0004
XML
Image XML parsing0.00010.018910.0001
class_abstraction
Instantiating content class attribute0.00000.000520.0000
General
dbfile0.00060.0850100.0001
String conversion0.00000.001340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
8content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 22
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs