CUSTOM FIELDS: General SMT Reference

Miva Knowledge Base
Want to start an online store? We work with you from start to finish, from commerce platform to design to SEO.
Experience counts, and we have a lot.
Important Notice: This information is for internal reference only. Use at your own risk.

CUSTOM FIELDS: General SMT Reference

Scot Ranney • February 22, 2024


Page Items / Miva Shortcuts - used for products, basket, customers, categories, pages

<mvt:item name="customfields" param="Read_Product_ID( l.settings:product:id, 'mainParentCat', l.settings:pmCustom:parent_cat)" />
<mvt:item name="customfields" param="Read_Category_ID( l.settings:category:id, 'ReviewProduct', l.settings:pmCustom:review_code)" />

Custom Field Selector in Store Templates, Data Sstructure 

l.settings:product:customfield_values:customfields:custom_field_code

Load a Product and then Load Custom Field Data

<mvt:do file="g.Module_Library_DB" name="l.success" value="Product_Load_Code('PRODUCT_CODE', l.settings:product)" />
<mvt:assign name="l.fieldcode" value="'some_code'" />
<mvt:do file="g.Module_Root $ '/modules/util/customfld.mvc'" name="l.success" value="ProductFieldValue_Load_CodeAndProduct(l.fieldcode, l.settings:product:id, l.field, l.settings:data)" />
Custom field value: &mvt:data:value;

Load All Custom Fields for a Store Item (Category, Product, Etc)

This will load a structure of all custom field data for a category. You can change the function to reflect a product and possibly page.

<mvt:do file="g.Module_Root $ '/modules/util/customfld.mvc'" name="l.ok" value="CategoryFieldList_Load_Values( l.settings:category:id,l.settings:cf )" />
<mvt:item name="scotstools" param="varvalues(l.settings:cf)" />

Page Custom Field Functions: This is the SEO tab on pages. All custom SEO fields are loaded this way, there are a couple defaults loaded with the page data structure.

  • PageFieldList_Load_All( fields var )
  • PageField_Load_Code( code,field var )
  • PageFieldValue_Load_CodeAndPage( code,page_id,pagever_id,field var,value var )
  • PageFieldValue_Set( field_id,page_id,pagever_id,value )
  • Etc - look in lsk for pagefield and find the relevant functions.
<mvt:do file="g.Module_Feature_TUI_DB" name="l.success" value="Page_Load_Code('Some_Page_code', l.settings:page)" />
<mvt:do file="g.Module_Feature_TUI_DB" name="l.success" value="PageVersion_Load_Page_Current(l.settings:page:id, l.pageversion)" />
<mvt:assign name="l.fieldcode" value="'seo_image'" />
<mvt:do file="g.Module_Root $ '/modules/util/customfld.mvc'" name="l.success" value="PageFieldValue_Load_CodeAndPage(l.fieldcode, l.settings:page:id, l.pageversion:id, l.field, l.settings:data)" />
&mvt:data:value;

Customer Custom Fields

<MvASSIGN NAME = "l.ok" VALUE = "{ [ g.Module_Root $ '/modules/util/customfld.mvc' ].CustomerFieldValue_Load_CodeAndCustomer('custom_field_code', l.settings:customer:id, l.settings:field, l.settings:value) }" />
<MvCOMMENT>
#
# sNN_CFM_CustFields
#
</MvCOMMENT>
<MvASSIGN NAME = "l.field"	VALUE = "">
<MvASSIGN NAME = "l.field:id"	VALUE = "{ CustomerFieldValues.d.id }">
<MvASSIGN NAME = "l.field:group_id"	VALUE = "{ CustomerFieldValues.d.group_id }">
<MvASSIGN NAME = "l.field:code"	VALUE = "{ CustomerFieldValues.d.code }">
<MvASSIGN NAME = "l.field:name"	VALUE = "{ CustomerFieldValues.d.name }">
<MvASSIGN NAME = "l.field:fieldtype"	VALUE = "{ CustomerFieldValues.d.fieldtype }">
<MvASSIGN NAME = "l.field:info"	VALUE = "{ CustomerFieldValues.d.info }">
<MvASSIGN NAME = "l.ok" VALUE = "{ [ g.Module_Root $ '/modules/util/customfld.mvc' ].CustomerField_Update(l.field) }" />
<MvCOMMENT>
#
# sNN_CFM_CustValues
#
</MvCOMMENT>
<MvASSIGN NAME = "l.value"	VALUE = "">
<MvASSIGN NAME = "l.value:field_id"	VALUE = "{ CustomerFieldValues.d.field_id }">
<MvASSIGN NAME = "l.value:product_id"	VALUE = "{ CustomerFieldValues.d.product_id }">
<MvASSIGN NAME = "l.value:value"	VALUE = "{ CustomerFieldValues.d.value }">
<MvASSIGN NAME = "l.value:value_long"	VALUE = "{ CustomerFieldValues.d.value_long }">
<MvASSIGN NAME = "l.ok" VALUE = "{ [ g.Module_Root $ '/modules/util/customfld.mvc' ].CustomerFieldValue_Set(l.field_id,l.customer_id,'some value') }" />

Product Fields

<MvASSIGN NAME = "l.ok" VALUE = "{ [ g.Module_Root $ '/modules/util/customfld.mvc' ].ProductFieldList_Load_All(l.customfields) }" />
<b>custom fields</b>
<MvFOREACH ITERATOR = "l.field" INDEX = "l.pos" ARRAY = "l.customfields">
<MvEVAL EXPR = "{ debugarray(l.field) }">
</MvFOREACH>

Load ALL Custom Field Values At Once

Works for all types of custom fields, including page custom fields (seo tab).

l.null_code is where the custom field code should be, but if it's null the function will load all the fields and values and put them in their own structures.

<MvASSIGN NAME = "l.ok" VALUE = "{ [ g.Module_Root $ '/modules/util/customfld.mvc' ].Read_Category_Code(l.module, '', l.category:code, l.null_code, l.custom_field_stuff) }" />

https://www.scotsscripts.com/mvblog/custom-fields-general-reference.html

mvkb_customfields