The ezprice datatype (Price)
Class eZPriceType in kernel/classes/datatypes/ezprice/ezpricetype.php; identifier ezprice, listed in settings/content.ini [DataTypeSettings] AvailableDataTypes[].
What it stores
The columns of the attribute tables its class reads or writes: data_float, data_float1, data_int1, data_text (data_text, data_int, data_float and sort_key_* are the object attribute's; data_text1 ... data_int4 the class attribute's settings). Found by reading the class: a heuristic.
Sorting: sortKeyType() returns int.
In templates
my_attribute stands for the identifier of an attribute of this type in your class:
def $attribute = $node.data_map.my_attribute
if $attribute.has_content
attribute_view_gui attribute=$attribute
/if
{* the value as the datatype returns it (objectAttributeContent()) *}
$attribute.content|attribute( show, 1 )The shipped template that shows it (attribute_view_gui), design/standard/templates/content/datatype/view/ezprice.tpl:
{* DO NOT EDIT THIS FILE! Use an override template instead. *}
if $attribute.content.has_discount
'Price'|i18n( 'design/standard/content/datatype' ): <strike>$attribute.content.inc_vat_price|l10n( currency )</strike> <br>
'Your price'|i18n( 'design/standard/content/datatype' ): $attribute.content.discount_price_inc_vat|l10n( currency )<br>
'You save'|i18n( 'design/standard/content/datatype' ): sub($attribute.content.inc_vat_price,$attribute.content.discount_price_inc_vat)|l10n( currency ) ( $attribute.content.discount_percent % )
else
'Price'|i18n( 'design/standard/content/datatype' ) $attribute.content.inc_vat_price|l10n( currency )<br>
/ifThe shipped template that edits it (attribute_edit_gui), design/standard/templates/content/datatype/edit/ezprice.tpl (first 25 lines):
{* DO NOT EDIT THIS FILE! Use an override template instead. *}
default attribute_base=ContentObjectAttribute
<div class="block">
<label for="ezcoa-if ne( $attribute_base, 'ContentObjectAttribute' )$attribute_base-/if$attribute.contentclassattribute_id_$attribute.contentclass_attribute_identifier_price">'Price'|i18n( 'design/standard/class/datatype' ):</label>
<input id="ezcoa-if ne( $attribute_base, 'ContentObjectAttribute' )$attribute_base-/if$attribute.contentclassattribute_id_$attribute.contentclass_attribute_identifier_price" class="ezcc-$attribute.object.content_class.identifier ezcca-$attribute.object.content_class.identifier_$attribute.contentclass_attribute_identifier" type="text" name="$attribute_base_data_price_$attribute.id" size="12" value="$attribute.content.price|l10n( clean_currency )" />
if $attribute.class_content.is_vat_included
{* Entered price already includes VAT. *}
else
(+ $attribute.content.selected_vat_type.name|wash, $attribute.content.selected_vat_type.percentage|wash%)
/if
</div>
<div class="block">
<label for="ezcoa-if ne( $attribute_base, 'ContentObjectAttribute' )$attribute_base-/if$attribute.contentclassattribute_id_$attribute.contentclass_attribute_identifier_vat">'VAT'|i18n( 'design/standard/class/datatype' ):</label>
<select id="ezcoa-if ne( $attribute_base, 'ContentObjectAttribute' )$attribute_base-/if$attribute.contentclassattribute_id_$attribute.contentclass_attribute_identifier_vat" class="ezcc-$attribute.object.content_class.identifier ezcca-$attribute.object.content_class.identifier_$attribute.contentclass_attribute_identifier" name="$attribute_base_ezprice_inc_ex_vat_$attribute.id">
<option value="1" if eq( $attribute.content.is_vat_included, true() )selected="selected"/if>'Price inc. VAT'|i18n( 'design/standard/class/datatype' )</option>
<option value="2" if eq( $attribute.content.is_vat_included, false() )selected="selected"/if>'Price ex. VAT'|i18n( 'design/standard/class/datatype' )</option>
</select>
</div>
<div class="block">
<label>'VAT type'|i18n( 'design/standard/class/datatype' ):</label>
{include uri='design:shop/vattype/edit.tpl'
select_name=concat( $attribute_base, "_ezprice_vat_id_", $attribute.id )Override them for one class attribute in an override.ini.append.php with Source=content/datatype/view/ezprice.tpl and a match on attribute_identifier (see A template override).
Related
Generated by ./console exp:help:examples from kernel/classes/datatypes/ezprice/ezpricetype.php, settings/content.ini, design/standard/templates/content/datatype/view/ezprice.tpl, design/standard/templates/content/datatype/edit/ezprice.tpl. Do not edit this page: change the source and generate again (how). Free documentation: GFDL 1.3 or later.