Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2009-07-03 14:39:41

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Specify article_custom limit AND check for non-empty custom field?

alannie wrote:

I was hoping to avoid having to assign a category, but it looks like this may be the only way for now (that doesn’t bog down the site, as Gocom pointed out).

Or try this plugin: no category required; not boggy.

Edit: Okay, having looked a little closer at Gocom’s post, I should qualify: not too boggy, at least not for most tastes. Does involve some extra queries, so not a solution if primo performance is a goal. But hardly noticeable in the context of a typical Txp install.

Last edited by jsoo (2009-07-03 14:44:08)


Code is topiary

Offline

#14 2009-07-03 15:07:39

alannie
Member
From: Minnesota, USA
Registered: 2005-09-15
Posts: 150

Re: Specify article_custom limit AND check for non-empty custom field?

jsoo wrote:

Or try this plugin: no category required; not boggy.

Wow!! You are fast – great documentation already in place too! I installed the plugin and it works beautifully. No noticeable bogginess as you predicted.

I’m a huge fan of your plugins and have soo_toc and soo_image installed as well. When are you adding a “Donate” button on your site? :)

Offline

#15 2009-07-03 15:20:54

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

Re: Specify article_custom limit AND check for non-empty custom field?

jsoo wrote:

try this plugin

Thanks, Jeff!

I was just about to gather my poor English and put up a plugin request. I had several sites where I could need exactly this. Each solved in the meantime, but I’m sure this here will get its chance!


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

Offline

#16 2009-07-03 17:17:22

artagesw
Member
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

Re: Specify article_custom limit AND check for non-empty custom field?

Bloke wrote:

artagesw’s solution is by far the simplest, but if you’re already using the categories for other things you’re stuck …

If you don’t want to burn categories for this, keywords provide another alternative.

Offline

#17 2009-07-03 22:09:05

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Specify article_custom limit AND check for non-empty custom field?

alannie wrote:

I’m a huge fan of your plugins and have soo_toc and soo_image installed as well. When are you adding a “Donate” button on your site? :)

Thanks alannie, very kind! I suppose if my plugin download rate and/or support thread traffic goes way up I’ll consider it, but for now I’m happy to share these plugins that I am finding useful myself. Of course, a donation to Txp is always welcome…


Code is topiary

Offline

#18 2009-07-03 22:37:15

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Specify article_custom limit AND check for non-empty custom field?

Hmm, I’m taking the long way round to find a simple solution, as usual. Guess what:

<txp:article_custom limit="3" video_id="_%" />

works. Might just have to mothball that plugin.


Code is topiary

Offline

#19 2009-07-03 22:51:47

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Specify article_custom limit AND check for non-empty custom field?

^^ what?! _% works like a wildcard? do you know the explanation?

jsoo, thanks for sharing this discovery…


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#20 2009-07-03 23:00:27

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Specify article_custom limit AND check for non-empty custom field?

See the ‘like’ function in MySQL, about a page down describes the wildcards. "%" is the equivalent of ".*" in PCRE syntax. "_" is the equivalent of ".". So "_%" is equivalent to ".+".


Code is topiary

Offline

#21 2009-07-03 23:17:55

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Specify article_custom limit AND check for non-empty custom field?

OMG, jsoo, you just started a whole new Txp era! Thank you :)

Offline

#22 2009-07-04 00:09:33

artagesw
Member
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

Re: Specify article_custom limit AND check for non-empty custom field?

Tread carefully there. That is likely an “unintended feature” that happens to work now but could break in the future. For one thing, it is MySQL-specific, which is something to watch out for if you want to maintain the flexibility of changing to a different database backend in the future.

Offline

#23 2009-07-04 00:20:20

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Specify article_custom limit AND check for non-empty custom field?

Yes, some words from wet about this “unintented feature” could be helpful to know if it’s safe to use it in the long run.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#24 2009-07-04 00:35:04

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Specify article_custom limit AND check for non-empty custom field?

From a quick survey the same pattern (and the operator LIKE) will also work in SQLite and PostgreSQL.

Edit: And I wouldn’t call it “unintended”. It was certainly intended by whoever chose to use LIKE instead of =, as shown by the following comment in the function in question (buildCustomSql() in publish.php):

# nb - use 'like' here to allow substring matches

Last edited by jsoo (2009-07-04 01:52:15)


Code is topiary

Offline

Board footer

Powered by FluxBB