Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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
andsoo_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
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
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…
Offline
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
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
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.
Offline
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