Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#169 2021-10-18 14:35:58

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

Re: Dev news

BTW, which features of list processing would be useful? Currently, txp 4.8.8 can

  • sort a list, in ascending/descending/random order;
  • filter/alter it via trim and replace attributes;
  • remove duplicates via valueless replace;
  • extract some of list items, via limit/offset attributes;
  • loop-parse list items via breakform.

What else?

Offline

#170 2021-10-18 16:39:52

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,060
Website GitHub Mastodon Twitter

Re: Dev news

etc wrote #331819:

What else?

As long as we can still combine them with custom_fields:)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#171 2021-10-18 18:17:41

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

Re: Dev news

colak wrote #331820:

As long as we can still combine them with custom_fields:)

Still? AFAIK, custom fields in 4.8.7 have no ‘list’ feature, and in 4.8.8 you can use it with any tag, including <txp:custom_field />. As for the future cf branch, I guess cf will have their own attributes that will take priority over the global ones.

I’m still unsure how to handle sort attribute: should the default be case-insensitive, like in MySQL? How to trigger the case-sensitive mode then? What about the ‘natural’ mode, where, say, img9.png precedes img10.png? Should it be something like sort="natcase asc"? Ideas welcome.

Offline

#172 2021-10-19 05:31:06

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,060
Website GitHub Mastodon Twitter

Re: Dev news

etc wrote #331821:

Still? AFAIK, custom fields in 4.8.7 have no ‘list’ feature, and in 4.8.8 you can use it with any tag, including <txp:custom_field />.

Maybe I’m missunderstanding what you mean with. list. In the article docs:

custom_n where n is the number of your custom field…

also

<txp:article colour="red" />


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#173 2021-10-19 09:58:52

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

Re: Dev news

colak wrote #331824:

Maybe I’m missunderstanding what you mean with. list. In the article docs:

I have certainly been not clear enough. Nothing changes for <txp:article /> and other ‘listing’ tags that handle these (sort etc) attributes themselves. It’s just about the ability to process the non-listing tags output as lists, like some plugins do.

For example, order keywords alphabetically:

<txp:keywords breakby="," break=", " sort />

Or display two random article images:

<txp:images id='<txp:custom_field name="article_image" breakby="," sort="rand" limit="2" />' />

Note that the latter can already be achieved in 4.8.7 in another way:

<txp:images id='<txp:custom_field name="article_image" />' sort="rand()" limit="2" />

Offline

#174 2021-10-19 13:54:38

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,060
Website GitHub Mastodon Twitter

Re: Dev news

etc wrote #331826:

It’s just about the ability to process the non-listing tags output as lists, like some plugins do.

For example, order keywords alphabetically:

<txp:keywords breakby="," break=", " sort />...

Or display two random article images:

<txp:images id='<txp:custom_field name="article_image" breakby="," sort="rand" limit="2" />' />...

Note that the latter can already be achieved in 4.8.7 in another way:

<txp:images id='<txp:custom_field name="article_image" />' sort="rand()" limit="2" />...

Oh!!! I understand now. Sounds yummy!!!


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#175 2021-11-12 10:47:53

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

Re: Dev news

The behaviour of the global escape attribute has been slightly changed when applied to lists. For example,

<txp:article_custom break=" and " escape="upper"><txp:title /></txp:article_custom>

in 4.8.7 would output

TITLE ONE AND TITLE TWO AND ...

and in 4.8.8 it will be

TITLE ONE and TITLE TWO and ...

Any objections to this?

Offline

#176 2021-11-12 12:26:00

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

Re: Dev news

The 4.8.8 behaviour seems more logical to me. The escape is being applied to the content, the break is added verbatim. I like it.


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

Online

#177 2021-11-12 15:03:43

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,536
Website GitHub Twitter

Offline

#178 2021-11-12 16:23:29

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,626
GitHub Twitter

Re: Dev news

Thanks lot Oleg!

I changed a very complex SQL query with this instead:

<txp:article_custom section='<txp:section />' break="" wraptag="ul" break="li" trim='/(.*)(@\s?)(\d+\))?/' sort="Title asc"><txp:title /></txp:article_custom>

Depending on my article titles in this form:

Title @number

The expected result is an unordered list of ascendant numbers 🤪

Last edited by Pat64 (2021-11-12 16:26:38)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#179 2021-11-13 09:25:03

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,135
Website

Re: Dev news

etc wrote #331934:

Any objections to this?

That seems more sensible, I think. I never used that transform though :).


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#180 2021-11-16 04:49:23

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,626
GitHub Twitter

Re: Dev news

@etc

From your example:

<txp:variable name="fruits" value="apple,banana,cranberry" />

<txp:variable name="fruits" breakby="," break="," sort="rand" />

Is there a way to remove duplicate data in order to keep only one?

<txp:variable name="fruits" value="apple,banana,cranberry,apple" />

<txp:variable name="fruits" breakby="," break="," sort="rand" />

Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

Board footer

Powered by FluxBB