Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-05-21 15:32:40

pfctdayelise
Member
From: Melbourne, Australia
Registered: 2007-05-18
Posts: 68
Website

Hooking into existing functionality - lists of articles/images

Hello,

I’ve written a small plugin that gets a list of image IDs based on their image aspect ratio. So putting <txp:bjl_image_ratio w="4" h="3" /> will get a list of images with ratio 4:3.

It also has an option to return a list of articles, that have article_images associated with them, whose images meet the specified ratio (since that was the functionality I originally wanted :) I was manually putting the images in ratio categories, then I thought, hey, if txp stores this info, no need for me to duplicate it…!).

So…how can I kind of hook this into existing functionality that does stuff like article lists and image lists? with paging.

wet_for_each_image might be useful too, somehow.

I don’t know TXP well enough, so I need help at this stage. :)

there’s a copy up here if anyone wants to take a peek.

thanks,
Brianna

Offline

#2 2007-05-26 08:21:59

pfctdayelise
Member
From: Melbourne, Australia
Registered: 2007-05-18
Posts: 68
Website

Re: Hooking into existing functionality - lists of articles/images

OK… I will try and explain a bit more what I’m trying to find out. First I will just talk about trying to get a list of articles that meet certain criteria. I have the list retrieved from the DB – now what?

In general, it’s a bit of a mystery to me that Textpattern has conditionals but not loop-type structures (for each…). Somehow these loops seem built into tags like txp:article and txp:article_custom based on “limit” attributes.

So.. I assumed these tags generated lists of relevant articles (or their IDs) based on the other attributes, and then produced some output for each of those articles (sent them to some specified or default form).

however… if that’s what’s going on here then…I’m lost.

How do the forms get the information about the relevant articles?

Say you have a form Foo with contents <txp:permlink><txp:title /></txp:permlink>. Compared to psuedocode, I would imagine it as

def Foo(article):
     return article.permlink(article.title())

So…am I thinking about this in an unhelpful metaphor, or…?

thanks,
Brianna

Offline

#3 2007-05-26 20:00:57

hakjoon
Moderator
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,633
Website

Re: Hooking into existing functionality - lists of articles/images

pfctdayelise wrote:
however… if that’s what’s going on here then…I’m lost.

I believe those are the functions to build the tag builders you see in the admin interface. The best place to start is in taghandlers.php This holds most of the functions. The article specific ones are in publish.php and they are mostly wrappers for parseArticles and doArticle.

Normally what happens is that a foreach creates a global ($thisarticle) and pushes it through parse() which handles all the tags. The result is pushed back into an array ($out[]) which is then run through doWrap() for wrap and break tags.

Something like related_articles() might give you a better idea. of how it works.

Last edited by hakjoon (2007-05-26 20:05:12)


Shoving is the answer – pusher robot

Offline

#4 2007-05-26 20:06:03

Mary
Sock Enthusiast
From: Canada
Registered: 2004-06-27
Posts: 6,235

Re: Hooking into existing functionality - lists of articles/images

You’re looking at the wrong bit of code; that is for the tagbuilder. What you are looking for is in textpattern/publish.php and textpattern/publish/taghandlers.php.


My email address has changed recently. If you need to contact me, use the forum contact form.

Offline

#5 2007-05-27 13:52:22

pfctdayelise
Member
From: Melbourne, Australia
Registered: 2007-05-18
Posts: 68
Website

Re: Hooking into existing functionality - lists of articles/images

thanks hakjoon and Mary. I will study those files dutifully… I also had a look at chh_article_custom and I will look at some more plugins that have similar functionality, to try and reuse as much core code as possible and avoid rewriting it myself.

Brianna

Offline

Board footer

Powered by FluxBB