Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Alphabetical list of articles in a section
BTW, we could add first to available escape values. Or even consider integer values as substring length:
<txp:variable name="hello" value="welcome" />
<txp:variable name="hello" escape="3" /> <!-- outputs 'wel' -->
<txp:variable name="hello" escape="-2" /> <!-- outputs 'me' or 'lcome' or 'welco'? -->
Offline
Re: Alphabetical list of articles in a section
Oooh interesting. If we’re going that way and it’s not going to clash with anything else…
<txp:variable name="hello" value="welcome" />
<txp:variable name="hello" escape="3" /> <!-- outputs 'wel' -->
<txp:variable name="hello" escape="3,4" /> <!-- outputs 'lcom'? -->
<txp:variable name="hello" escape="-2" /> <!-- outputs 'me'? -->
<txp:variable name="hello" escape="5,-2" /> <!-- outputs 'co'? -->
<txp:variable name="hello" escape="-5,4" /> <!-- outputs 'lcom'? -->
The only thing with using the from,count syntax is that it differs from PHP’s substr() insofar as it starts from 1 and not 0, for consistency with the single count syntax. That might confuse programmers at first, but everyone else should get it.
EDIT: not really sure if ‘escape’ is the right terminology though. If we’re doing this, shouldn’t we introduce a new global attribute? I’d suggest expanding trim (since we’re trimming the text by a number of characters) except it’s currently used to trim alphanumerics, and an integer is a valid character you might want to strip off.
Last edited by Bloke (2020-01-08 22:23:02)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: Alphabetical list of articles in a section
Oleg, that is some superb tag-fu you are displaying. Splendid.
I’m trying hard to understand – taking notes along with the URL of the thread to test and analyse once I am past the first strong cold of the year (ginger tea with the last of the yuzu).
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
Re: Alphabetical list of articles in a section
phiw13 wrote #320957:
(ginger tea with the last of the yuzu).
Yum…
Bloke wrote #320953:
not really sure if ‘escape’ is the right terminology though. If we’re doing this, shouldn’t we introduce a new global attribute? I’d suggest expanding
trim(since we’re trimming the text by a number of characters) except it’s currently used to trim alphanumerics, and an integer is a valid character you might want to strip off.
Yep, escape will not do since comma is used as separator there. We could adopt 1%%9 syntax used in custom fields filter, and trim suits better indeed. But I’m not sure we need it in such a generality: extracting/removing 3 first letters can be useful on plugins/themes sites, but other cases look exotic.
Offline
Re: Alphabetical list of articles in a section
etc wrote #320960:
Yep,
escapewill not do since comma is used as separator there.
Ah of course. If you think escape with an integer just for removing everything but the given N letters is worthwhile, by all means stick it in.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline