Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveosoule/da212c4fcf6a1157f490033f5c09f342 to your computer and use it in GitHub Desktop.
Save steveosoule/da212c4fcf6a1157f490033f5c09f342 to your computer and use it in GitHub Desktop.
Miva - Smart-Breadcrumbs s.http_referer Adjustment Global Pre-Render
<mvt:comment>
|---------------------------------------------------------------------
| SMART-BREADCRUMBS S.HTTP_REFERER ADJUSTMENT
|---------------------------------------------------------------------
| Alters Smart-Breadcrumbs & Category-Tree behavior that always
| loads breadcrumb hierarchies based on s.http_referer; even when
| the refering category is not in the product's hierarchy.
|---------------------------------------------------------------------
| 1.) Check Referring Category
| 2.) Check Current Request's Product
| 3.) Check if the Product is assigned to the Referring Category
| 4.) If the product is not assigned to the referring category,
then set g.Category_Code to a category that the product is assigned to.
| 5.) Debugging Helper
|=--------------------------------------------------------------------
</mvt:comment>
<mvt:if expr="g.domain:name CIN s.http_referer AND g.Screen EQ 'PROD'">
<mvt:comment>
| 1.) Check Referring Category
</mvt:comment>
<mvt:assign name="l.referrer:http" value="s.http_referer" />
<mvt:do file="g.Module_Feature_URI_UT" name="l.referrer:normalized_uri" value="URL_To_Normalized_URI( l.referrer:http )" />
<mvt:do file="g.Module_Feature_URI_DB" name="l.success" value="URI_Load_URI( l.referrer:normalized_uri, l.referrer:uri )" />
<mvt:if expr="NOT l.referrer:uri:cat_id"><mvt:exit /></mvt:if>
<mvt:do file="g.Module_Library_DB" name="l.success" value="Category_Load_ID( l.referrer:uri:cat_id, l.referrer:category )" />
<mvt:if expr="NOT l.referrer:category:id"><mvt:exit /></mvt:if>
<mvt:comment>
| 2.) Check Current Request's Product
</mvt:comment>
<mvt:assign name="l.request:http" value="s.request_uri" />
<mvt:do file="g.Module_Feature_URI_UT" name="l.request:normalized_uri" value="URL_To_Normalized_URI( l.request:http )" />
<mvt:do file="g.Module_Feature_URI_DB" name="l.success" value="URI_Load_URI( l.request:normalized_uri, l.request:uri )" />
<mvt:if expr="NOT l.request:uri:product_id"><mvt:exit /></mvt:if>
<mvt:do file="g.Module_Library_DB" name="l.success" value="Product_Load_ID( l.request:uri:product_id, l.request:product )" />
<mvt:if expr="NOT l.request:product:id"><mvt:exit /></mvt:if>
<mvt:comment>
| 3.) Check if the Product is assigned to the Refering Category
</mvt:comment>
<mvt:do file="g.Module_Library_DB" name="l.request:categorylist:result" value="CategoryList_Load_Offset_Product_Assigned( l.request:product:id, 0, '', '', 0, l.request:categorylist:nextoffset, l.request:categorylist:categories )" />
<mvt:assign name="l.referrer:is_products_category" value="miva_array_search( l.request:categorylist:categories, 0, l.category, 'l.category:id EQ \'' $ l.referrer:cateogry:id $ '\'' )" />
<mvt:comment>
| 4.) If the product is not assigned to the refering category, then set g.Category_Code to category that the product is assigned to.
</mvt:comment>
<mvt:if expr="NOT l.referrer:is_products_category">
<mvt:if expr="l.request:product:cancat_id">
<mvt:do file="g.Module_Library_DB" name="l.success" value="Category_Load_ID( l.request:product:cancat_id, l.request:product:cancat )" />
<mvt:assign name="g.Category_Code" value="l.request:product:cancat:code" />
<mvt:elseif expr="miva_array_elements( l.request:categorylist:categories )">
<mvt:assign name="l.request:categorylist:first" value="miva_array_shift( l.request:categorylist:categories )" />
<mvt:assign name="g.Category_Code" value="l.request:categorylist:first:code" />
</mvt:if>
</mvt:if>
<mvt:comment>
| 5.) Debugging Helper
</mvt:comment>
<mvt:if expr="g.debug">
<mvt:assign name="g.mvt_debug" value="glosub( miva_array_serialize( l.referrer ), ',', asciichar( 10 ) )" />
<!--
@@ Global Pre Render: referrer
============
&mvt:global:mvt_debug;
-->
<mvt:assign name="g.mvt_debug" value="glosub( miva_array_serialize( l.request ), ',', asciichar( 10 ) )" />
<!--
@@ Global Pre Render: request
============
&mvt:global:mvt_debug;
-->
</mvt:if>
</mvt:if>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment