Mark Hughes
05-10-06, 08:05 PM
A key element of Store Morph Technology is the item. Items contain information drawn from the database and also embody the ability to display that information in a particular way. Item extensions modify the data before the primary item displays it.
Underlying every item for use in templates is a component module. These modules contain the MIVA Script instructions that extract information from the database and make it accessible through the l.settings array and entity tags in the template. Component modules also contain the MIVA Script instructions that direct the creation of the HTML code that Empresa inserts in place of the item start and end tags when processing the template.
The Basket Contents module (cmp-mmui-basket), via its initialization function, loads the Basket Contents item (code = ?basket?) with the information about the products currently contained in the customer?s basket, along with any information about the product attributes, sales tax, shipping charges, subtotal, total etc.. It also contains instructions, in the render functions, about how to display that information.
The purpose of some component modules is to provide item extensions; that is to alter the data provided by another component module. With item extension modules, it is possible to adjust the information that, for instance, the Basket Contents item displays (perhaps, say, appending a 5 star rating to the end of selected product names), without having entirely to replace cmp-mmui-basket.mvc and alter the templates to point at a replacement basket item. Additionally or alternatively, one might choose to add additional pieces of information to an item, say, a count of all the products in the basket. Templates could then access this information through the l.settings array or via entities.
Plug the following pieces of code into the build system <http://smallbusiness.miva.com/support/docs/api/> to obtain a module capable of extending the Basket Contents (code = ?basket?) item. The first adjustment incorporated in this module is to add a setting by the name of ?prodcount? to the basket item. This item represents the number of products currently in the basket. Once you have this module assigned as an extension to the basket item, you will be able to use code in the template such as this below:
<mvt:if expr="l.settings:basket:prodcount">
<p>Total # of items in basket: &mvt:basket:prodcount;<p>
</mvt:if>
Note: the module as written does not automatically assign/unassign itself as an extension.
Is there additional information about the basket you would like to have available in the template?
Inputs to the build system to produce example extension module:
cmp-mv-basket_ext.mv
<MvComment>
Basket Contents Extension Component Module
</MvComment>
<MvFUNCTION NAME = "SubComponentModule_Initialize" PARAMETERS = "module var, item, all_settings var, settings var" STANDARDOUTPUTLEVEL = "">
<MvIFDEF NAME="DEBUG_TRACE">
<MvEVAL EXPR="{ '<HR color="#ff0000"> <b>' $ l.module:code $ ' <i>stub</i></b> SubComponentModule_Initialize(module var, item, all_settings var, settings var)<br>' }">
</MvIFDEF>
<MvCOMMENT>Add a new member to the structure containing settings for the basket contents item.</MvCOMMENT>
<MvASSIGN NAME = "l.all_settings:basket" MEMBER = "prodcount" VALUE = "{miva_array_elements(l.all_settings:basket:items)}">
<MvFUNCRETURN VALUE = "{1}">
</MvFUNCTION>
Makefile
# Basket Extension Module
#
#
MODULE_SOURCE= cmp-mv-basket_ext.mv
MODULE_CODE= cmp-mv-basket_ext
MODULE_NAME= Basket Extension
MODULE_PROVIDER= MIVA Small Business
MODULE_VERSION= 5.0000
MODULE_APIVERSION= 5.00
MODULE_FEATURES= component
include ../Makerules
Underlying every item for use in templates is a component module. These modules contain the MIVA Script instructions that extract information from the database and make it accessible through the l.settings array and entity tags in the template. Component modules also contain the MIVA Script instructions that direct the creation of the HTML code that Empresa inserts in place of the item start and end tags when processing the template.
The Basket Contents module (cmp-mmui-basket), via its initialization function, loads the Basket Contents item (code = ?basket?) with the information about the products currently contained in the customer?s basket, along with any information about the product attributes, sales tax, shipping charges, subtotal, total etc.. It also contains instructions, in the render functions, about how to display that information.
The purpose of some component modules is to provide item extensions; that is to alter the data provided by another component module. With item extension modules, it is possible to adjust the information that, for instance, the Basket Contents item displays (perhaps, say, appending a 5 star rating to the end of selected product names), without having entirely to replace cmp-mmui-basket.mvc and alter the templates to point at a replacement basket item. Additionally or alternatively, one might choose to add additional pieces of information to an item, say, a count of all the products in the basket. Templates could then access this information through the l.settings array or via entities.
Plug the following pieces of code into the build system <http://smallbusiness.miva.com/support/docs/api/> to obtain a module capable of extending the Basket Contents (code = ?basket?) item. The first adjustment incorporated in this module is to add a setting by the name of ?prodcount? to the basket item. This item represents the number of products currently in the basket. Once you have this module assigned as an extension to the basket item, you will be able to use code in the template such as this below:
<mvt:if expr="l.settings:basket:prodcount">
<p>Total # of items in basket: &mvt:basket:prodcount;<p>
</mvt:if>
Note: the module as written does not automatically assign/unassign itself as an extension.
Is there additional information about the basket you would like to have available in the template?
Inputs to the build system to produce example extension module:
cmp-mv-basket_ext.mv
<MvComment>
Basket Contents Extension Component Module
</MvComment>
<MvFUNCTION NAME = "SubComponentModule_Initialize" PARAMETERS = "module var, item, all_settings var, settings var" STANDARDOUTPUTLEVEL = "">
<MvIFDEF NAME="DEBUG_TRACE">
<MvEVAL EXPR="{ '<HR color="#ff0000"> <b>' $ l.module:code $ ' <i>stub</i></b> SubComponentModule_Initialize(module var, item, all_settings var, settings var)<br>' }">
</MvIFDEF>
<MvCOMMENT>Add a new member to the structure containing settings for the basket contents item.</MvCOMMENT>
<MvASSIGN NAME = "l.all_settings:basket" MEMBER = "prodcount" VALUE = "{miva_array_elements(l.all_settings:basket:items)}">
<MvFUNCRETURN VALUE = "{1}">
</MvFUNCTION>
Makefile
# Basket Extension Module
#
#
MODULE_SOURCE= cmp-mv-basket_ext.mv
MODULE_CODE= cmp-mv-basket_ext
MODULE_NAME= Basket Extension
MODULE_PROVIDER= MIVA Small Business
MODULE_VERSION= 5.0000
MODULE_APIVERSION= 5.00
MODULE_FEATURES= component
include ../Makerules