Share » Forums » Setup & design » Overriding how an object name looks?

Overriding how an object name looks?

Overriding how an object name looks?

Thursday 13 October 2005 6:52:57 pm - 1 reply

Author Message

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

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu