Miva Merchant Modules and Development
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.

URIS/URLS: Loading URI System with Legacy Fallback

Scot Ranney • December 22, 2023


10.08 Note: As of 10.08 all page related URI functions use page_code instead of page_id.

Not all stores use the URI system unfortunately. For mivascript and smt coding sometimes this needs to be taken into account.

Product URI Loading Example (mivascript)

<MvASSIGN NAME = "l.ok" VALUE = "{ [ g.Module_Feature_URI_DB ].URI_Load_Product_Canonical( l._product:id, l._canonical ) }" />
<MvASSIGN NAME = "l.url" VALUE = "{ l._canonical_uri:uri }" />
<mvt:comment> ## if it could not get the uri that way, then do it old style ## </mvt:comment>
<MvIF EXPR = "{ NOT l.url }">
	<MvASSIGN NAME = "l.url" VALUE = "{  [ g.Module_Feature_URI_UT ].Store_Product_URL( l._product, l.flags )  }" />
</MvIF>

Page URI Loading (smt) - note, in 10.08 the function changed to use page:code instead of page:id

<mvt:do file="g.Module_Feature_URI_DB" name="l.success" value="URI_Load_Page_Canonical(l.settings:page:code, l.settings:canonical_uri)" />

&mvt:canonical_uri:uri;

Product URI (smt)

<mvt:assign name="l.settings:_product:id" value="2" />

<mvt:do file="g.Module_Feature_URI_DB" name="l.settings:uri" value="URI_Load_Product_Canonical(l.settings:_product:id, l.settings:canonical)" />

Canonical: &mvt:canonical:uri;

Structure:

<MvASSIGN NAME = "l.uri:id"		VALUE = "{ URIs.d.id }">
<MvASSIGN NAME = "l.uri:uri"		VALUE = "{ URIs.d.uri }">
<MvASSIGN NAME = "l.uri:screen"		VALUE = "{ URIs.d.screen }">
<MvASSIGN NAME = "l.uri:store_id"	VALUE = "{ URIs.d.store_id }">
<MvASSIGN NAME = "l.uri:page_id"	VALUE = "{ URIs.d.page_id }">
<MvASSIGN NAME = "l.uri:cat_id"		VALUE = "{ URIs.d.cat_id }">
<MvASSIGN NAME = "l.uri:product_id"	VALUE = "{ URIs.d.product_id }">
<MvASSIGN NAME = "l.uri:feed_id"	VALUE = "{ URIs.d.feed_id }">
<MvASSIGN NAME = "l.uri:canonical"	VALUE = "{ URIs.d.canonical }">
<MvASSIGN NAME = "l.uri:status"		VALUE = "{ URIs.d.status }">

Load ANY URI With One Function

This is the god function of URIs.

Set any page, cat, product, screen, feed, or store:

<mvt:assign name="l.uri:store_id" value="g.Store:id" />
<mvt:assign name="l.uri:screen" value="''" />
<mvt:assign name="l.uri:page_code" value="0" />
<mvt:assign name="l.uri:cat_id" value="0" />
<mvt:assign name="l.uri:product_id" value="1" />

<mvt:do file="g.Module_Feature_URI_DB" name="l.have_uri" value="URI_Load_Item_Canonical( l.uri, l.settings:canonical_uri )" />

<mvt:if expr="l.have_uri">
	Link: &mvt:canonical_uri:canonical; 
	<br>
	&mvt:canonical_uri:cat_id;
	<br>
	&mvt:canonical_uri:page_code;
	<br>
	&mvt:canonical_uri:status;
	<br>
	&mvt:canonical_uri:store_id;
	<br>
	&mvt:canonical_uri:uri;
</mvt:if>

For reference, the URI_READ function is used here and sets up the following structure:

<MvFUNCTION NAME = "URI_Read" PARAMETERS = "uri var" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.uri:id"			VALUE = "{ URIs.d.id }">
	<MvASSIGN NAME = "l.uri:uri"		VALUE = "{ URIs.d.uri }">
	<MvASSIGN NAME = "l.uri:screen"		VALUE = "{ URIs.d.screen }">
	<MvASSIGN NAME = "l.uri:store_id"	VALUE = "{ URIs.d.store_id }">
	<MvASSIGN NAME = "l.uri:page_id"	VALUE = "{ URIs.d.page_id }">
	<MvASSIGN NAME = "l.uri:cat_id"		VALUE = "{ URIs.d.cat_id }">
	<MvASSIGN NAME = "l.uri:product_id"	VALUE = "{ URIs.d.product_id }">
	<MvASSIGN NAME = "l.uri:feed_id"	VALUE = "{ URIs.d.feed_id }">
	<MvASSIGN NAME = "l.uri:canonical"	VALUE = "{ URIs.d.canonical }">
	<MvASSIGN NAME = "l.uri:status"		VALUE = "{ URIs.d.status }">
</MvFUNCTION>

https://www.scotsscripts.com/mvblog/urisurls-loading-uri-system-with-legacy-fallback.html

mvkb_uri