steveosoule
2/13/2017 - 10:24 PM

Miva - Category Cascade List for URIs

Miva - Category Cascade List for URIs

<mvt:do file="g.Module_Root $ '/modules/component/cmp-mv-prodctgy-meta.mvc'" name="l.success" value="CategoryCascadeList_Load_Category( l.settings:category, l.settings:category:list )" /><mvt:foreach iterator="item" array="category:list"><mvt:assign name="l.settings:category:uri" value="l.settings:category:uri $ '/' $ l.settings:item:code" /></mvt:foreach><mvt:assign name="l.settings:category:uri" value="l.settings:category:uri $ '.html'" />&mvt:category:uri;
<!--
  -----------------------------------------------------------------
  Generates URIs that use a categories parent categories in the URI
  -----------------------------------------------------------------
  
  Given a store with a category/sub-category structure like this:
  
  - appliances
    - kitchen
      - refrigerators
      
  It will generate Miva XML Provisioning for a category URI like this:
  
  /appliances/kitchen/refrigerators.html
  
-->
<mvt:do file="g.Module_Library_DB" name="l.success" value="CategoryList_Load_All( l.settings:categories )" />

<mvt:foreach iterator="category" array="categories">
	<mvt:do file="g.Module_Root $ '/modules/component/cmp-mv-prodctgy-meta.mvc'" name="l.success" value="CategoryCascadeList_Load_Category( l.settings:category, l.settings:category:list )" />
	
	<mvt:comment>
	  <!--
	    When there is only one item in the `category:list`,
	    these URIs have already been generated by Miva's URI management template: `/&mvts:category:code;.html`
	  -->
	</mvt:comment>
	<mvt:if expr="miva_array_elements( l.settings:category:list ) EQ 1">
		<mvt:foreachcontinue/>
	</mvt:if>
	
	<mvt:foreach iterator="item" array="category:list">
		<mvt:assign name="l.settings:category:uri" value="l.settings:category:uri $ '/' $ l.settings:item:code" />
	</mvt:foreach>
	<mvt:assign name="l.settings:category:uri" value="l.settings:category:uri $ '.html'" />
	
	<mvt:assign name="l.settings:xml" value="l.settings:xml $ '<uri_add category_code=\"' $ l.settings:category:code $ '\" status=\"200\" uri=\"' $ l.settings:category:uri $ '\" />'" />
</mvt:foreach>

&mvte:xml;
<!-- Take this output, and import it using, "Import Data and Settings in XML Provisioning Format" -->