Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#325 2020-01-22 16:06:35

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,702
Website

Re: etc_query: all things Textpattern

If you don’t mind using (a very useful) plugin, you can do it more simply with smd_wrap.

See Example 7 in the docs for the auto_excerpt case. If you wrap that additionally in <txp:if_excerpt><txp:excerpt /><txp:else /> … </txp:if_excerpt>, then your own excerpt will be used if it exists first.

@bloke: you have a v0.3 of this plugin but it’s not available online in compiled form. I’ll see if I can find mine… It is now, and you can find it here (thanks bloke :-).

@Karsten: If you let us know which other plugins you are needing to update, we may be able to advise…


TXP Builders – finely-crafted code, design and txp

Offline

#326 2020-01-22 23:10:38

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

Re: etc_query: all things Textpattern

@jakob: Thanks, released.


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

#327 2020-01-23 15:40:44

Karsten
Member
From: Leiden, Netherlands
Registered: 2011-04-24
Posts: 47
Website

Re: etc_query: all things Textpattern

@jakob THANKS

this is briljant, and does exactly what I want:

<txp:smd_wrap_all transform=“strip_tags, cut|35w|&hellip;”>
<txp:body />
</txp:smd_wrap_all>

Simply gives the first 35 words of the body text, that was what I needed!

As for other plugins that stopped working: rah_textile_bar

This was a useful tool that added buttons to apply textile, very convenient to use! But is doesn’t seem to do anything any more. If I come across more plugins that have failed I will let you know.

Offline

#328 2020-01-23 16:11:24

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

Re: etc_query: all things Textpattern

Not that I’m jealous, but now (4.8-dev) you can get it in core:

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

Offline

#329 2020-01-23 16:44:43

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

Re: etc_query: all things Textpattern

etc wrote #321296:

Not that I’m jealous, but now (4.8-dev) you can get it in core:

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

Oleg,
You never cease to amaze me! 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.

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


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

Offline

#330 2020-01-23 17:26:53

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

Re: etc_query: all things Textpattern

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


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

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

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

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: 5,133
Website GitHub

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: 11,415
Website GitHub

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

Offline

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

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

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

Offline

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

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

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: 11,415
Website GitHub

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

Offline

Board footer

Powered by FluxBB