Page 1 of 1

Products Module - Customize List View based on Cat or Hier

Posted: Thu Jan 31, 2019 6:42 pm
by digitalman
Hi,

I'm trying and failing to understand how to access and call some of the more advanced features of Products templating. Specifically, I'm trying to change the template design of the LIST VIEW depending how you get there (hierarchy view or category view).

My best attempt so far is to try programming "IF this set of products CONTAINS one hierarchy, print one thing (say, a hierarchy image). If it has more than one hierarchy, print something else (a category image, or no image at all)." This will activate if you choose a category that contains products with multiple hierarchies.

I'm not sure how to program Smarty to "count all of the unique values of hierarchy in this set." I tried the code below, but this only counts the total number of products... Not very handy:

Code: Select all

{assign 'get_hierarchy_info' value=$Products->GetHierarchyInfo($items[0]->hierarchy_id)}

  {if $get_hierarchy_info.count gt 1}
    THIS DISPLAYS IF PAGE HAS MULTIPLE HIERARCHIES
  {else}
   THIS DISPLAYS IF PAGE HAS ONLY ONE HIERARCHY
  {/if}
If you know how to do what I'm trying, or have a better idea for customizing list views based on the values of the product set, pleasssse let me know!

O0

Re: Products Module - Customize List View based on Cat or Hi

Posted: Fri Feb 01, 2019 11:38 am
by Rolf
The category view urls contain "bycategory" and the hierarchy view contain "byhierarchy".
Knowing this you can read that part of the page url in your Products Summary list view and do your stuff according to the view....

Add this in your template and add the content as your wish...

Code: Select all

{$page_url = $smarty.get.page|default:''}

{if strpos($page_url, 'bycategory') !== false}
    {* We have a category view!! *}
{/if}

{if strpos($page_url, 'byhierarchy') !== false}
    {* We have a hierarchy view!! *}
{/if}