Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#313 2018-12-10 10:37:40

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

Re: etc_query: all things Textpattern

Here is something to make you start:

<txp:variable name="contlist">
<txp:article_custom wraptag="ul">
<txp:etc_query data='<txp:custom_field name="ONIX_record" escape="" />'
    query="//Product/Contributor[ContributorRole='B06']/PersonNameInverted"
    markup="xml" break="li"
>{?}</txp:etc_query>
</txp:article_custom>
</txp:variable>

<txp:etc_query data='<txp:variable name="contlist" />'>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" />
<xsl:template match="ul">
	<dl>
	<xsl:for-each select="li">
		<xsl:sort select="." order="ascending" />
		<txp:if_different><dt><strong><xsl:copy-of select="substring(text(), 1, 1)" /></strong></dt></txp:if_different>
		<dd><xsl:copy-of select="text()" /></dd>
	</xsl:for-each>
	</dl>
</xsl:template>
</xsl:stylesheet>
</txp:etc_query>

Offline

#314 2019-03-18 15:01:43

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

Re: etc_query: all things Textpattern

After every 3 paragraphs I add my phrase. Now I use this:

<txp:etc_query data='<txp:body />' separator="|\/|" replace='p[2]$=<txp:output_form form="remark_1" />|\/| p[4]$=<txp:output_form form="remark_2/>"/> |\/| p[8]$=<txp:output_form form="remark_3"/>' />

I want to complicate the task. It is necessary to add a phrase to the article for the section and for the category.

Separately, such a request works:

<txp:output_form form='remark_1-<txp:section/><txp:category/>' />

<txp:output_form form='remark_2-<txp:section/><txp:category/>' />

<txp:output_form form='remark_3-<txp:section/><txp:category/>' />

But etc_query doesn’t work:

<txp:etc_query data='<txp:body />' separator="|\/|" replace='p[2]$=<txp:output_form form='remark_1-<txp:section/><txp:category/>' />|\/| p[6]$=<txp:output_form form='remark_2-<txp:section/><txp:category/>'/> |\/| p[10]$=<txp:output_form form='remark_3-<txp:section/><txp:category/>' />' />

I do not understand how to do it right.

How can I add a category and / or section?


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

Offline

#315 2019-03-18 15:24:17

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

Re: etc_query: all things Textpattern

Hello,

you should duplicate quotes inside quotes:

<txp:etc_query data='<txp:body />' separator="|\/|"
    replace='p[2]$=<txp:output_form form=''remark_1-<txp:section/><txp:category/>'' />|\/|
        p[6]$=<txp:output_form form=''remark_2-<txp:section/><txp:category/>''/> |\/|
        p[10]$=<txp:output_form form=''remark_3-<txp:section/><txp:category/>'' />' />

Hope that helps.

Offline

#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,187
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,306

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,306

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,090
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

Board footer

Powered by FluxBB