Products Module - Customize List View based on Cat or Hier

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
digitalman
New Member
New Member
Posts: 3
Joined: Thu Nov 29, 2018 9:34 pm

Products Module - Customize List View based on Cat or Hier

Post 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
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

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

Post 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}
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Post Reply

Return to “Modules/Add-Ons”