Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#181 2013-08-18 17:34:06

juanjo
Member
From: A Coruña, Spain
Registered: 2005-08-01
Posts: 55
Website

Re: etc_query: all things Textpattern

Thanks Oleg, my mistake!

But I still can not get the data from fields like {swell/minBreakingHeight?} e.g., from the specific timestamp. I try this query:

query="//localTimestamp[. ='1376784000']"/*

But it does not work, obviously.

Offline

#182 2013-08-18 17:43:29

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

Re: etc_query: all things Textpattern

Yes, because swell is a sibling of localTimestamp, not its child. Try

query="//localTimestamp[.='1376784000']/following-sibling::swell/minBreakingHeight"

if you wan just this data, or

query="//localTimestamp[.='1376784000']/.."

to match the parent of the desired timestamp, then {swell/minBreakingHeight?} and other selectors inside etc_query.

Offline

#183 2013-08-18 18:10:03

juanjo
Member
From: A Coruña, Spain
Registered: 2005-08-01
Posts: 55
Website

Re: etc_query: all things Textpattern

Thanks a lot again, Oleg! it works perfectly :)

Offline

#184 2013-08-18 18:30:46

juanjo
Member
From: A Coruña, Spain
Registered: 2005-08-01
Posts: 55
Website

Re: etc_query: all things Textpattern

Oleg, sorry for being such a pain in the ass, but it would be possible to replace the datestamp in the query for the current datestamp using something like this?

<txp:php>
        $now = time();
        $date = date('m/d/Y H', $now) . ':00';
        $currenttime = strtotime($date);       
</txp:php>

then

query="//localTimestamp[. =misterious code $currenttime]/.."

Offline

#185 2013-08-18 21:56:33

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

Re: etc_query: all things Textpattern

Sure, the usual parsing rules apply, just mind the quotes. You can even do it etc_query-way, calling query="//localTimestamp[.='{?||strftime(%F %H:00).strtotime}']/..". However, there is no guarantee that this timestamp will be present in the feed. Edit: you can use query="//localTimestamp[.>='{?||strftime(%F %H:00).strtotime}']/.." to find the immediate successor of the current timestamp.

Last edited by etc (2013-08-18 22:09:32)

Offline

#186 2013-08-25 08:45:44

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 3,013

Re: etc_query: all things Textpattern

Hi Oleg.
If you have time (and inclination), I’d appreciate a pointer on where I’m going wrong with the following. I want to query and display database contents, specifically the ip field of txp_discuss with a provided discussid. My SQL syntax is correct, I think, but this isn’t outputting anything when used in a comment form:

<txp:etc_query data="SELECT ip FROM txp_discuss WHERE discussid = <txp:comment_id />">{ip?}</txp:etc_query>

Thank you in advance.

Online

#187 2013-08-25 09:16:44

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

Re: etc_query: all things Textpattern

Hi Pete, I think that’s just double quotes:

<txp:etc_query data='SELECT ip FROM txp_discuss WHERE discussid = <txp:comment_id />'>{ip?}</txp:etc_query>

or even

<txp:etc_query data='SELECT ip FROM txp_discuss WHERE discussid = <txp:comment_id />' />

should be ok.

Offline

#188 2013-08-25 09:18:15

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 3,013

Re: etc_query: all things Textpattern

etc wrote:

Hi Pete, I think that’s just double quotes:

Guh! The one thing I didn’t try!

Thank you, Oleg.

Online

#189 2013-09-04 09:58:09

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

Re: etc_query: all things Textpattern

Version 1.2.7: minor update to enable LDAP queries (data is composed of ;-separated rdn, filter and only fields):

<txp:etc_query markup="ldap" url="ldaps://my.ldap.server:636" data="ou=people,dc=org; uid=ol*; uid,sn" query="count" />

Works for me, but testers are more than welcome.

Edit: also tightened the security a little bit: only privileged users can import data from url or databases.

Last edited by etc (2013-09-04 10:49:30)

Offline

#190 2013-09-12 19:14:57

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

Re: etc_query: all things Textpattern

Version 1.2.8: few changes inspired by this thread:

  • new save attribute, allowing to save the imported and transformed dom tree, that can be quickly reused later with markup="data";
  • new {!variable} pattern, that will be actualized on each call, and not only once like {?variable} pattern;
  • new {##} pattern for internal nodelist number;
  • more secure: requires php privileges for all advanced operations.

Offline

Board footer

Powered by FluxBB