Forums / Setup & design / Overriding how an object name looks?

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}
------

eZ debug

Timing: Jan 21 2025 17:13:19
Script start
Timing: Jan 21 2025 17:13:19
Module start 'content'
Timing: Jan 21 2025 17:13:19
Module end 'content'
Timing: Jan 21 2025 17:13:19
Script end

Main resources:

Total runtime0.3327 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0084 588.9297180.8281
Module start 'content' 0.00840.0106 769.757893.7734
Module end 'content' 0.01890.3137 863.5313523.0781
Script end 0.3327  1,386.6094 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00381.1412200.0002
Check MTime0.00130.4034200.0001
Mysql Total
Database connection0.00090.277110.0009
Mysqli_queries0.257277.29971410.0018
Looping result0.00170.51331390.0000
Template Total0.313294.110.3132
Template load0.00100.308710.0010
Template processing0.312193.804510.3121
Override
Cache load0.00070.223110.0007
Sytem overhead
Fetch class attribute can translate value0.00090.263810.0009
XML
Image XML parsing0.00030.080510.0003
General
dbfile0.01785.3368200.0009
String conversion0.00000.002830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

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

Time used to render debug report: 0.0002 secs