LISE - drill down to other LISE using LISE Instance Item Topic is solved

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
przemo
Forum Members
Forum Members
Posts: 23
Joined: Mon Dec 30, 2013 12:58 pm

LISE - drill down to other LISE using LISE Instance Item

Post by przemo »

Hi,
First of all I have written this topic and this topic on this forum but I did not find a solution of my problem.

First Instance is LISEproduct, second LISEmaterials.
In LISEmaterials there is Category field definition to group items by category like wood, metal, aluminum and so on.
In LISEproduct there is Material field definition (alias: material) type: LISE Instance Item, sub-type jquery multiselect.

In a detail view of each product I drill down to materials of this specific product by using

Code: Select all

{LISEmaterials include_items="{$item->material}" template_summary="product-card"}
And here I would like the materials to be divided into their categories, not loosely listed like:
- material 1, category: wood
- material 2, category: metal
- material 3, category: wood
- material 4, category: wood
(the aluminum category is not displayed because no material has been selected)

Put simply, I want to get this effect:

Category Wood:
- material 1
- material 3
- material 4
Category Metal:
- material 2

Anyone have an idea how to do this?
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1628
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: LISE - drill down to other LISE using LISE Instance Item

Post by DIGI3 »

I think you could do this by calling category mode for the result

Code: Select all

{LISEmaterials action=category show_items=true ... }
Possibly include_items could be an array converted to csv so you're only calling it once, but I'd have to experiment with that.

If you wanted to continue with the method you're already using, you should be able to sort by category, then do the category breaks in your template with a bit of Smarty logic.
Not getting the answer you need? CMSMS support options
przemo
Forum Members
Forum Members
Posts: 23
Joined: Mon Dec 30, 2013 12:58 pm

Re: LISE - drill down to other LISE using LISE Instance Item

Post by przemo »

hi!

Code: Select all

{LISEmaterials action=category show_items=true ... }
This would be great solution, but unfortunately it lists all the categories and content - unrelated to the product we're browsing at the moment.
As you know, I cannot use the additional parameter like

Code: Select all

{LISEmaterials action=category show_items=true include_items=$item-> material}
So the question is how to do it later (in the category template) to display categories and materials belong to them, but only related to the currently viewed product?
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1628
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: LISE - drill down to other LISE using LISE Instance Item

Post by DIGI3 »

In your item, create a csv variable with all the related categories, and use that as the category= value. If you need further matching (whatever is used to determine if it's relative to your product) then you'd do an if in the category template, or give them classes with the relationship values and hide them as needed.
Not getting the answer you need? CMSMS support options
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: LISE - drill down to other LISE using LISE Instance Item

Post by velden »

Try this code in your product-card template:

Code: Select all

{* array to store items per category ID *}
{* requires one, and only one, category per item *}
{$tmpArray=[]}

{* iterate all items and store them in the array under their category id *}
{if $items|@count > 0}
  {foreach from=$items item=item}
     {$tmpArray[$item->fielddefs.category->value][]=$item}
  {/foreach}
{/if}

{* sort array by category ID!!! *}
{$dummy=$tmpArray|@ksort}

{* iterate found category IDs *}
{foreach from=$tmpArray key=catid item=catitems}
  {* load the the category object to get its name  *}
  {LISELoader item='category' value=$catid assign=cat}
  <h3>{$cat->name}</h3>
  <ul>
  {* finally iterate the items for the category and print their title *}
  {foreach from=$catitems item=item}
    <li>{$item->title}</li>
  {/foreach}
  </ul>
{/foreach}
przemo
Forum Members
Forum Members
Posts: 23
Joined: Mon Dec 30, 2013 12:58 pm

Re: LISE - drill down to other LISE using LISE Instance Item

Post by przemo »

Thank you Velden - it works!
I really dont know how or why ::) but that solves my problem.
I owe you a "cup of coffee".

DIGI3 - I appreciate you wanting to help,

thank you one more time guys.
Locked

Return to “Modules/Add-Ons”