Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2025-09-24 08:30:09

etc
Developer
Registered: 2010-11-11
Posts: 5,502
Website GitHub

Re: RFC: extracting distinct values

Bloke wrote #340633:

<article::custom section='<txp:section />' fields="thisid, list(brand)" break="" limit="0">...

should build me a unique comma-separated list of custom_5 values from articles in that section.

The intended use is fields="section, list(brand)", though this will not remove duplicates.

Since GROUP_CONCAT() supports DISTINCT clause, this is easy to add. It makes sense then to sort by brand too. I wouldn’t like to alter list() behaviour, so a new syntax is needed. Should it be unique() or distinct() or something else?

Offline

#26 2025-09-24 08:55:53

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,986
Website GitHub

Re: RFC: extracting distinct values

etc wrote #340645:

The intended use is fields="section, list(brand)", though this will not remove duplicates.

Oh. So I need section as well, because I’m filtering by section= in the tag? Maybe that’s where I was going wrong

I wouldn’t like to alter list() behaviour, so a new syntax is needed. Should it be unique() or distinct() or something else?

Either works for me. distinct() is more SQLish.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#27 2025-09-24 09:17:31

etc
Developer
Registered: 2010-11-11
Posts: 5,502
Website GitHub

Re: RFC: extracting distinct values

Bloke wrote #340646:

Oh. So I need section as well, because I’m filtering by section= in the tag? Maybe that’s where I was going wrong

No, you are right, not in this case.

Offline

#28 2025-09-24 09:25:39

etc
Developer
Registered: 2010-11-11
Posts: 5,502
Website GitHub

Re: RFC: extracting distinct values

Bloke wrote #340646:

Either works for me. distinct() is more SQLish.

If list() sounds like distinct and sorted, we can yet alter it this way, I don’t think it is widely used. Then concat() would replace it for raw concatenations.

Offline

Board footer

Powered by FluxBB