Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#316 2019-03-18 16:13:40

singaz
Member
Registered: 2017-03-12
Posts: 150

Re: etc_query: all things Textpattern

I checked. It is working.

Thank you, Oleg!


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

Offline

#317 2019-03-18 16:20:47

singaz
Member
Registered: 2017-03-12
Posts: 150

Re: etc_query: all things Textpattern

P.S.

Question out of curiosity.

How to write this in a container?

<txp:etc_query>
....
</txp:etc_query>

I can not do it


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

Offline

#318 2019-03-18 18:42:05

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

Re: etc_query: all things Textpattern

singaz wrote #317140:

How to write this in a container?

You can rename your forms to remark_2-... (6, 10, …), and try something like

<txp:etc_query data='<txp:body />' query="*">
    {.}
    <txp:evaluate query="{#row}=2 or {#row}=6 or {#row}=10">
        <txp:output_form form='remark_{#row}-<txp:section /><txp:category />' />
    </txp:evaluate>
</txp:etc_query>

This will insert the forms after the 2nd, 6th and 10 HTML node, not necessary p. The body must be well structured.

Offline

#319 2019-03-19 10:33:06

singaz
Member
Registered: 2017-03-12
Posts: 150

Re: etc_query: all things Textpattern

Plugin contains great features. Need to learn to work with them. I try.

Thank you!


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

Offline

#320 2020-01-22 13:05:44

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

Re: etc_query: all things Textpattern

Hi, can somebody help me.

I updated my site to the newest version of Textpattern, which was long overdue, but as a result some plugins have stopped working, including rss_auto_excerpt.

So now I’m trying to use etc_query to do either the same, or a similar thing. I simply want to call up the <txp:body /> but limit the output to the first 50 words. That’s it.

I found the following code:

<txp:etc_query data='<txp:body />' replace="//@style" query="p[1]" />

which will output only the first paragraph of the article’s body text, which is a start, but is there a way to simply limit it to the first 50 words?

Thanks

Last edited by Karsten (2020-01-22 13:08:16)

Offline

#321 2020-01-22 14:21:24

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,316

Re: etc_query: all things Textpattern

Karsten wrote #321259:

… which was long overdue, but as a result some plugins have stopped working, including rss_auto_excerpt.

Hi Karsten, the “long overdue” part makes me think that those plugins might be easy to repair following these two advice as most plugins were broken at some point (4.6?) and could be fixed that way. Advantage: You might continue using your existing plugin tags.

In case you want to benefit from 4.7’s from/to changes, here’s another easy fix. And some hints on how to repair several other plugins.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#322 2020-01-22 15:15:41

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

Re: etc_query: all things Textpattern

Thanks, but I’m not really into PHP myself, wouldn’t really know where to start. On the forum page of the specific plugin it is simply stated that it is orphaned.

rah_metas can do more or less the same thing, but uses the functionality to generate meta tags (and this one does work in the newest TXP). So it should not be so difficult in itself. But unfortunately it is too difficult for me to figure it out

Offline

#323 2020-01-22 15:45:22

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,316

Re: etc_query: all things Textpattern

I can’t write a single line of PHP on my own, but I could with ease fix all plugins I used.

Mostly it’s been tag registration, which is as simple as pasting the code from the link here to the start of the plugin code, and for each tag your plugin provides you add a line with the function’s name, like Ruud explained.

As an example, here’s the complete list from com_connect, one tag on each line.

// Register tags if necessary.
if (class_exists('\Textpattern\Tag\Registry')) {
    Txp::get('\Textpattern\Tag\Registry')
        ->register('com_connect')
        ->register('com_connect_text')
        ->register('com_connect_email')
        ->register('com_connect_textarea')
        ->register('com_connect_select')
        ->register('com_connect_option')
        ->register('com_connect_checkbox')
        ->register('com_connect_radio')
        ->register('com_connect_serverinfo')
        ->register('com_connect_secret')
        ->register('com_connect_submit')
        ->register('com_connect_send_article')
        ->register('com_connect_value')
        ->register('com_connect_label')
        ->register('com_connect_if');
}

Just note the semicolon after the last register line. I.e. if you can write text with correct punctuation, you should have no difficulty.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#324 2020-01-22 15:46:01

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

Re: etc_query: all things Textpattern

Hi Karsten,

rah_metas is no longer needed as txp currently offers meta description tags for sections, categories and individual pages.

Re the rss_auto_excerpt plugin, do check Oleg’s patch or preferably, experiment with Julian’s no plugins solution, and Oleg’s more optimised contribution, further down in the thread.


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

Offline

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

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,205
Website GitHub

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: 12,465
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.

Hire Txp Builders – finely-crafted code, design and Txp

Online

#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,680
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,388
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: 12,465
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.

Hire Txp Builders – finely-crafted code, design and Txp

Online

Board footer

Powered by FluxBB