Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-05-27 00:08:32

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

Any way of passing a custom SQL query for txp:article(_custom)?

I have a simple event list with an ‘event start date’ and ‘event finish date’ as custom fields. I have txp:article_custom to list my events and in the article form msv_if_custom_article_date checks whether the ‘event finish date’ of an event has passed and if so, does not display it.

It works just fine for longer lists, however for lists with a low limit= attribute (such as limit="3" which I am using for 3 frontpage teaser links) it will only show 2 event-articles when for instance 1 of the 3 events has elapsed. Looking at the tag trace txp:article_custom sources 3 event-articles from the db, then tests whether they should be shown.

So I need to check to see if the custom field value has ‘elapsed’ in the database query itself. According to the tag trace the standard txp SQL syntax does a custom_field LIKE value. In this case I need to compare it against the current time.

How might I achieve this? Can the article_custom function be called using <txp:php>echo article_custom... and feed a custom request? If so, how should I write it?


TXP Builders – finely-crafted code, design and txp

Offline

#2 2007-05-27 10:56:25

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Any way of passing a custom SQL query for txp:article(_custom)?

You’ll probably have to write your own plugin, duplicating the article_custom/doArticles code in textpattern/publish.php to be able to do what you want. There’s no way to feed a custom SQL query to the article_custom tag.

Offline

#3 2007-05-27 18:21:01

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

Re: Any way of passing a custom SQL query for txp:article(_custom)?

There’s no way to feed a custom SQL query to the article_custom tag.

Thanks for the clarification, ruud.

You’ll probably have to write your own plugin, duplicating the article_custom/doArticles code in textpattern/publish.php

Ok, I made the change to chh_article_custom instead, duplicating takshaka’s chh_sql_time function to work with ‘custom_2’ rather than ‘Posted’ and added an additional attribute customtime=“future/past/any” to call it. That seems to work just fine now.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB