Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#331 2020-01-23 17:48:07

etc
Developer
Registered: 2010-11-11
Posts: 3,989
Website

Re: etc_query: all things Textpattern

colak wrote #321297:

This is way beyond what I expected txp to do out of the box!!! I cannot even pretend that I understand the syntax, but I am incredibly impressed.

Textpattern is a magic wand, but the wizardry is yours. A quick regex introduction will completely demystify the trick.

Offline

#332 2020-01-23 17:51:01

etc
Developer
Registered: 2010-11-11
Posts: 3,989
Website

Re: etc_query: all things Textpattern

Bloke wrote #321298:

I’ll add that example to the docs for the excerpt tag.

Wouldn’t it fit better as new global replace attribute example (since we have to document it anyway)?

Offline

#333 2020-01-23 17:59:38

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,848
Website

Re: etc_query: all things Textpattern

etc wrote #321301:

Wouldn’t it fit better as new global replace attribute example (since we have to document it anyway)?

Sure, we can add something similar there too. Or maybe another type of example. Just thought it’d be nice for people who are looking to excerpt an article to see there are a few ways to do it without having to use the tag itself.


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

#334 2020-01-23 18:03:07

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,848
Website

Re: etc_query: all things Textpattern

Question: for documentation purposes, does replace only work to replace stuff matched by trim or can it be used on its own?


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

#335 2020-01-23 18:12:50

etc
Developer
Registered: 2010-11-11
Posts: 3,989
Website

Re: etc_query: all things Textpattern

Bloke wrote #321304:

Question: for documentation purposes, does replace only work to replace stuff matched by trim or can it be used on its own?

Hmm, what could it replace without trim? If you see…

Edit: probably replace is misleading. What is the opposite of trim?

Offline

#336 2020-01-23 18:32:39

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,848
Website

Re: etc_query: all things Textpattern

etc wrote #321305:

Hmm, what could it replace without trim? If you see…

I figured as much. Just wasn’t sure if the regex syntax could be used like sed with /find/replace/g. But that’s probably pushing it!

I agree that trim/replace isn’t the most obvious pairing but can’t think of anything else.


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

#337 2020-01-23 19:24:19

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,358
Website

Re: etc_query: all things Textpattern

Maybe it should go to as many places as possible. This is so much of a brilliant example for so many places:

  • replace
  • trim
  • excerpt.
  • body

For the third we could have an example like

<txp:if_excerpt>
	<txp:excerpt />
<txp:else />
	<txp:body escape="tags" trim="/^\W*((?:\w+\W+){35})\w.*$/s" replace="$1&hellip;" />
</txp:if_excerpt>

It may be a good idea to also link to the regex intro recommended by Oleg, possibly in the trim page. Finally as it is basically using the body tag, can we actually leave it out of there? :)


Yiannis
——————————
neme.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.

Offline

#338 2020-01-23 19:33:53

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,358
Website

Re: etc_query: all things Textpattern

etc wrote #321305:

probably replace is misleading. What is the opposite of trim?

augment, expand, extend, complete, …

augment sounds ok but it’ might be a lot to type and its very prone to typos:)


Yiannis
——————————
neme.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.

Offline

#339 2020-01-23 20:03:23

singaz
Member
From: Kyiv, Ukraine
Registered: 2017-03-12
Posts: 143

Re: etc_query: all things Textpattern

colak wrote #321297:


We should add the above in the docs under the body and excerpt as it seems to be of use for many.

Add absolutely necessary!!!

Often needed function


Sorry my horror English. I’m learning textpattern, I’m learning English

Offline

#340 2020-01-23 21:50:46

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,848
Website

Re: etc_query: all things Textpattern

The only thing that kinda makes sense, besides find/replace is cut/replace, but since we already have ‘trim’ that makes it a tad tricky, unless we allow overlap of the new ‘cut’ and phase out ‘trim’ in a few versions.

Not sure. But I can live with trim/replace.


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

Board footer

Powered by FluxBB