3 years ago
2
Topic

Hi

didn't anyone here ever need a seb_blog template where you can GROUP items according to a field ?

the need is to display events grouped by months. The end result would be

january

event1 event2 event3

february

event4 event5 event6

march

event7 event8 event9

and so on

so far we used lists within lists but it's a bit heavy 

thanks for sharing

cyril

Get a VIP membership
3 years ago
1
Level 1

I must add I first tried with a free query:

SELECT group_concat(ct.title),ev.ev_event_month FROM #__content as ct INNER JOIN #__cck_store_form_event as ev ON (ct.id=ev.id) WHERE ct.catid=31 GROUP BY ev.ev_event_month


but then the list result does not display the group_concat(ct.title) !



215 Posts
iliil
3 years ago
0
Level 2

Hi Cyril

MySQL GroupConcat function can be an option for this, but I am not sure if the best one. In order to make it work you have to 

1) Add the alias to the result e.g. group_concat(...) AS event_data

2) Create a free sotrage (no table selected) field called event_data

3) You have to explode the output in php using explode() function to get an array

What to watch out for

1) Use a good separator in groupconcat function, not just comma, if the concatenate data are strings. the best is to use some asci character

2) The default maximum length of groupconcat function output string is 1024, in case you have larger output, you have to extend it somehow.

Good Luck

Michal

Get a Book for SEBLOD