Page 1 of 1

[SOLVED] Products Module - How to use Hierarchy as full menu

Posted: Mon Mar 09, 2015 8:35 pm
by jmonline
Hello. I have been using CMSMS for some time for multiple basic sites, but I now need to create a site which will list products. I have setup the Products module and am having a couple of issues getting to grips with it.

My first stumbling block is that I wish to have a sidebar on the page which shows a list of the Hierarchy as links. I can get it to show with the following:

Code: Select all

<ul>
{foreach from=$hierdata key='key' item='item'}
<li><a href="{$item.url}">{$item.name}</a></li>
{/foreach}
</ul>
However when you then click one of the Hierarchy links to view the products within that hierarchy, the sidebar list is empty - I suspect it is trying to show child hierarchy items, of which there are none. I just want it to show the full hierarchy list at all times.

I've searched all the forums, but I am getting lost and haven't been able to pinpoint my issue. What am I missing?

Perhaps I am going about it the wrong way (I'm open to suggestions). Should be a very simple product site.... approx 15 top level hierarchy sections, each with about 10 products in. Want the list of the hierarchy's to show on the right of every page, and be able to click a hierarchy link to view the 10 products under that section.

Thanks in advance.
James :)


Cms Version: 1.11.13
Installed Modules:
CMSMailer: 5.2.2
CMSPrinting: 1.0.5
FileManager: 1.4.5
MenuManager: 1.8.6
MicroTiny: 1.2.9
ModuleManager: 1.5.8
News: 2.15
Search: 1.7.12
ThemeManager: 1.1.8
CGExtensions: 1.45
CGSimpleSmarty: 1.7.4
JQueryTools: 1.3.4
Products: 2.22.1
CGSmartImage: 1.17.2

Re: Products Module - How to use Hierarchy as full menu

Posted: Tue Mar 10, 2015 8:45 am
by velden
Assuming you're using the action='hierarchy' parameter on the {Products} tag:

From help:
(optional) parent="" - Applicable only in the hierarchy action, this parameter specifies the hierarchy id of the starting location of the report. If this parameter is specified, then the $active_hierarchy smarty variable will be ignored. If neither is set, then the hierarchy view will start from the root.

Re: Products Module - How to use Hierarchy as full menu

Posted: Tue Mar 10, 2015 10:15 am
by jmonline
Thanks for the reply Velden

So my page template looks like this currently

Code: Select all

<!-- start right product menu -->
<div id="right-menu" style="float:right;">
{Products action='hierarchy' hierarchytemplate='FinishedSidebar' }
</div>
<!-- end right product menu -->
If I add

Code: Select all

parent=""
to the {Products...} tag I get an empty list. Is there something obvious I'm missing?

This whole Products module is really testing me, it's not what I'm used to unfortunately.

James

Re: Products Module - How to use Hierarchy as full menu

Posted: Tue Mar 10, 2015 10:53 am
by velden
I suppose a hierarchy has a root. That root should have an id as shown in the 'Item Hierarchy' tab. Try to use that for parent parameter:

Example:

Code: Select all

{Products action='hierarchy' hierarchytemplate='FinishedSidebar' parent="123"}

or without quotes

{Products action='hierarchy' hierarchytemplate='FinishedSidebar' parent=123}
I'm just guessing as I never used it myself this way.

Re: Products Module - How to use Hierarchy as full menu

Posted: Tue Mar 10, 2015 11:10 am
by jmonline
Thanks, I'll have another play around.

Do you think I'm requesting something that's not common? My thought process is...

I need to use Hierarchy in the products module to be able to place the products into a relevant section

This should allow me to enter a "section" (Hierarchy) and display only the products which are within that section.

For my menu I want all of my "sections" to show on the menu at any time. So if my hierarchy is as follows:
--Clothes
--Shoes
--Hats
--Accessories
I should be able to create a menu that shows each of these sections within a <li> tag. So that when you click on Clothes, you are taken to the page showing all the products under the Clothes hierarchy. But when you are in the clothes section, you may want to look at Shoes, so the full menu list of sections should be visible.

Hope that makes sense.

Re: Products Module - How to use Hierarchy as full menu

Posted: Tue Mar 10, 2015 12:30 pm
by Rolf

Re: Products Module - How to use Hierarchy as full menu

Posted: Tue Mar 10, 2015 7:15 pm
by jmonline
Thanks for the suggestions, I've spent all day looking and fiddling around and still cannot get it to work :-\

I've found out that all 1st level hierarchy items have a parent_id of -1

So I was wondering if I could use this -1 as the basis to create the list of hierarchy so...

where parent_id = -1 show hierarchy.name - But I cannot work out how to run it.

I'd imagine people must be using something similar somewhere since how else would you have a navigation menu show all the hierarchy within your products module? I assume most people's navigation menus don't stop working once you are on a page which is under the 1st level of the hierarchy?

If I was to look at it another way. Say I had a shop laid out with hierarchy as follows:

Code: Select all

-Clothes
--Mens Clothes
--Womens Clothes
-Shoes
--Mens Shoes
--Womens Shoes
-Hats
-Accessories
How would you show that on your top navigation menu?

To clarify, from the top level (when not inside one of the hierarchy), I am able to print a list of all the hierarchy members below this top level.
From within a 1st level hierarchy item, I am able to print a list of all child hierarchy items.
I am NOT able to print the list of all 1st level hierarchy items from within a 1st level item.

Hopefully that makes sense :)

Thanks

Re: Products Module - How to use Hierarchy as full menu

Posted: Wed Mar 11, 2015 8:53 am
by velden
Try:

Code: Select all

{Products action='hierarchy' hierarchytemplate='FinishedSidebar' parent=-1}

Re: Products Module - How to use Hierarchy as full menu

Posted: Wed Mar 11, 2015 11:27 am
by jmonline
Velden, you are a genius... :) That's exactly what I needed to make it work - thank you.

In case anyone else requires this setup - here's how I have it configured.

In my page template I have the following:

Code: Select all

<!-- start sidebar-->
<div id="sidebar" style="float:right;">
{Products action='hierarchy' hierarchytemplate='Sidebar_menu' parent=-1}
</div>
<!-- end sidebar-->
Then in my Products module, as a Hierarchy template called 'Sidebar_menu' I have the following code:

Code: Select all

{* sidebar menu template *}

<div id="menu-sidebar">
<ul>
{foreach from=$hierdata key='key' item='item'}
<li><a href="{$item.down_url}">{$item.name}</a></li>
{/foreach}
</ul>
</div>
This then displays on every page of my side (regardless of current position in the hierarchy):

Code: Select all

<!-- start sidebar-->
<div id="sidebar" style="float:right;">

<div id="menu-sidebar">
<ul>
<li><a href="/products/hierarchy/13/25/Clothes">Clothes</a></li>
<li><a href="/products/hierarchy/14/25/Hats">Hats</a></li>
<li><a href="/products/hierarchy/15/25/Shoes">Shoes</a></li>
<li><a href="/products/hierarchy/16/25/Accessories">Accessories</a></li>
</ul>
</div>
</div>
<!-- end sidebar-->
I will now expand this onto my live site which will contain many more categories.

I shall mark this post as SOLVED. Thank you for everyone's support and I hope I can return the favor in the future.