Page 1 of 1

Listit2 - Can detail template display sibling items?

Posted: Thu Apr 03, 2014 9:12 am
by JM6891
Hi there,

I'm using the Listit2 module and was wondering if there was a way to display 3 x random sibling items?

When I say sibling items, I have various categories which my items are in. At the bottom of the detail page I'd like to display 3 random items from within the same category as the current detail page item. Does this make sense and is this possible?

Thanks in advance

Re: Listit2 - Can detail template display sibling items?

Posted: Thu Apr 03, 2014 10:03 am
by zaidcrowe
I think it would - I don't have the cms in front of me atm - but the detail template should be able to tell you which cateogry that item is in.

You then call a summary template using Listit2 as normal specifiying this category, this template should utilize something like this: http://www.i-do-this.com/snippets/Show- ... -arrays/56

Which will randomise the items, then all you have to do is loop through the newly created array, with a limit of 3 for loop :)

Re: Listit2 - Can detail template display sibling items?

Posted: Thu Apr 03, 2014 10:16 am
by JM6891
Hi, thank you very much for your reply.

I will have a play and see what I come up with. Thank you for your help!

Re: Listit2 - Can detail template display sibling items?

Posted: Thu Apr 03, 2014 10:30 am
by zaidcrowe
Pleasure :)

Re: Listit2 - Can detail template display sibling items?

Posted: Thu Apr 03, 2014 2:48 pm
by Stikki
Howdy,

If you navigated into item from category URL, then variable: $category is assigned by default. This applies to all frontend actions.

This means you can call something like this inside your detail template:

{ListIt2Instance category=$category->category_alias pagelimit=3 orderby='rand'}

This way everything is DB driven and you wont cause extra load time with Smarty.

If you didn't navigate into item using category links, then current category object ain't available and you have to use {ListIt2Loader} to load category data into variable and then use that data.

This works with ListItExtended 1.4.1 +

Re: Listit2 - Can detail template display sibling items?

Posted: Thu Apr 03, 2014 6:30 pm
by zaidcrowe
Way more elegant, I've never done this with listit before so didn't realise it was baked in!