Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#241 2015-09-12 09:33:41

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

Re: etc_query: all things Textpattern

Nothing to be sorry about, that helped me to fix few glitches.

Offline

#242 2015-09-12 09:46:27

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

Re: etc_query: all things Textpattern

Version 1.3.1 is out, just few minor fixes and 4.6 compatibility.

Offline

#243 2015-09-12 12:41:35

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: etc_query: all things Textpattern

etc wrote #294749:

Version 1.3.1 is out, just few minor fixes and 4.6 compatibility.

Thanks!

Any advice about the use of regex to allow me to create excerpt from the boby tag properly? My code is:

<txp:etc_query data='<txp:body />' specials="" query="substring(//p[1], 0, 140)" limit="1" wraptag="p" />

…but, of course, it does not cut properly. Cutting after the last entire word before the character 140 would be better.

Edit: it’s maybe even possible to add &hellip;?

Last edited by NicolasGraph (2015-09-12 12:43:26)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#244 2015-09-12 16:50:43

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

Re: etc_query: all things Textpattern

You can register any php (string) function for use with etc_query. I’m not sure this is optimal, but it should work:

<txp:etc_query data='<txp:body />' specials="" functions="preg_replace,trim" limit="1" wraptag="p"
    query="preg_replace('/\w*:::/', '&hellip;', preg_replace('/^(.{140}).+/s', '$1:::', trim(string(p[1]))))" />

Edit: but be careful if you use it inside another etc_query, you might need to protect the {140} part.

Last edited by etc (2015-09-12 21:20:19)

Offline

#245 2015-09-12 17:04:58

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: etc_query: all things Textpattern

etc wrote #294752:

You can register any php (string) function for use with etc_query. I’m not sure this is optimal, but it should work.

Thank you Oleg…


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#246 2015-09-23 14:01:35

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: etc_query: all things Textpattern

Hi,
I would like to know if there is any chance to make the following code work…
I’m looking for three comma separated image id’s in the article_image field but I can’t make REGEXP work.
Is that possible? Do I need to use the functions attribute? …

<txp:etc_query data="Image REGEXP '^((\d+,)\s*){2}\d+$'" populate="article">
	<txp:article_image />
</txp:etc_query>

Thanks…


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#247 2015-09-23 17:40:41

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

Re: etc_query: all things Textpattern

No, but since you are in db mode here, you must use MySQL regexp notations, which are weird. Try (no warranty)

<txp:etc_query markup="db" populate="article"
	data="Image REGEXP '^(([[:digit:]]+,)[[:space:]]*){2}[[:digit:]]+$'"
>
	<txp:article_image />
</txp:etc_query>

Offline

#248 2015-09-24 20:58:44

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: etc_query: all things Textpattern

etc wrote #295096:

No, but since you are in db mode here, you must use MySQL regexp notations, which are weird. Try (no warranty)

<txp:etc_query markup="db" populate="article"...

Thanks, I’ll give it a try and learn more about MySQL regexp notations after holydays.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#249 2015-10-17 14:22:36

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: etc_query: all things Textpattern

NicolasGraph wrote #295093:

Hi,
I would like to know if there is any chance to make the following code work…
I’m looking for three comma separated image id’s in the article_image field but I can’t make REGEXP work.
Is that possible? Do I need to use the functions attribute? …

<txp:etc_query data="Image REGEXP '^((\d+,)\s*){2}\d+$'" populate="article">...

Thanks…

I can’t get it work but it is not really important. Thank you for your reply.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#250 2015-10-17 15:46:21

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

Re: etc_query: all things Textpattern

That works for me, but may be server-dependent.

Offline

Board footer

Powered by FluxBB