Textpattern Forum

You are not logged in. Register | Login | Help

#11 2009-07-03 09:31:17

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,866
Website

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

Gocom’s right, it pulls out a maximum of 3 fields and then looks at the custom field contents. If all of them happen to have video_id set, you’re good to go. If not, you’ll see fewer articles.

artagesw’s solution is by far the simplest, but if you’re already using the categories for other things you’re stuck with Gocom’s “grab all articles and filter using txp:variables/smd_if”, some PHP or a one-stop smd_query. fwiw, off the top of my head, this should work:

<txp:smd_query query="SELECT * FROM textpattern WHERE video_id != '' ORDER BY Posted desc LIMIT 3">
<a href="/{Section}/{url_title}">{Title}</a>
</txp:smd_query>

EDIT: fix braindead 1st attempt

Last edited by Bloke (2009-07-03 09:35:15)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#12 2009-07-03 12:19:49

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

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

Thanks everybody for your feedback. Manqui, I had the same thought you did but then realized the videos have different and totally unrelated ids. They are posted on different services (google, youtube, etc.) and I’m using the the_video plugin to embed them. If they were all on the same service and ids were assigned consecutively, conceivably I’d then simply be able to sort by id. But alas, that is not the case.

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). Thanks all!

Offline

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

jsoo
Developer
From: NC, USA
Registered: 2004-11-15
Posts: 1,730
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)


Txp tags not doing what you expect? Learn to use a tag trace. And the Tag Reference.

Offline

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

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

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/Köln
Registered: 2006-08-15
Posts: 3,059

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
Developer
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
Developer
From: NC, USA
Registered: 2004-11-15
Posts: 1,730
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…


Txp tags not doing what you expect? Learn to use a tag trace. And the Tag Reference.

Offline

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

jsoo
Developer
From: NC, USA
Registered: 2004-11-15
Posts: 1,730
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.


Txp tags not doing what you expect? Learn to use a tag trace. And the Tag Reference.

Offline

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

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
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
Developer
From: NC, USA
Registered: 2004-11-15
Posts: 1,730
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 ".+".


Txp tags not doing what you expect? Learn to use a tag trace. And the Tag Reference.

Offline

Board footer

Powered by FluxBB