Hi! 

So I've this scenario where I want to display content (a list of categories and sub categories) with an accordion and i want it to be grouped by Category. 

What is happening right now is that when i've more than 1 subcategory that ''belongs'' to a category, it repeats the category. The source of that data is a record list, where i tried to use the option of ''group by'' but that leaves me with only a structure where i can't use the other attributes.

Solution

Hello Carolina,

How I have tackled this scenario is by having a list of the categories, without joining it to the sub categories yet.

Then I create a webblock that has the CategoryId as an input. Then this webblock will be a list of Subcategories filtered by CategoryId. This webblock is used in the Categories list. 

That is how I have accomplished what you are trying to without getting into the whole SQL Groupings complications.

Andres Moreno

Solution

i tried to use 2 tables separately but what i think cant use 2 tables as ''content'' for the accordion widget ...

Thats why you contain the list in a webblock, when the list is inside the webblock you can use it inside an accordion.

If you can share your OML so I can see what you are doing it can be helpful. 


Thanks

What Andre Moreno is saying is the correct way to do this when you need to use a list inside a list.


Here is an simple example of what you want to do.


Don't pay attention to the advance queries.

the first query you should get your categories only

Inside the webblock you need do a query that return you the subcategory where category is equal the value you are passing in CategoryId.


BR

It worked, thaaanks !

Could you mark the question as solved please.

I want to use the subcategory that I click to another screen, (i want to do a screen where i show every ''posts'' that exist on that subcat) but i can't access to it so i cant use an variable. how can i fix this?


br

Hi Carolina,

if I understand correctly you want to jump to a new screen when clicking on subcategories, is that correct? 

If that's the case, and considering the example provided by Carlos, you just need to go to the weblock that lists subcategories and create a link to a new screen.

In that new screen, you need to add an Input Parameter to receive the subcategory and be able to do aggregate (aka query) with it, where you are going to retrieve all the posts from that subcategory.


Does this help?