Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-07-12 11:49:41

koopd
Member
From: Chester, United Kingdom
Registered: 2005-01-03
Posts: 13
Website

How does the <txp: /> tag work?

I wonder if anyone would be able to explain to me how the <txp: /> tag is implemented in PHP, I would like to use this kind of feature in my own PHP applications.

Thanks


koopd.com
seventytwo.co.uk
—-
Graphic Designer, Wed Designer and Developer.

Offline

#2 2005-07-12 13:41:49

paularms
Member
From: University of Minnesota
Registered: 2004-10-21
Posts: 155
Website

Re: How does the <txp: /> tag work?

I suggest reading through files in the /textpattern/publish directory. The functions in those files find tags that start with <txp: /> and then match the function together and strip out the <txp:foo /> tag.

Last edited by paularms (2005-07-12 13:42:15)

Offline

#3 2005-07-12 13:46:59

koopd
Member
From: Chester, United Kingdom
Registered: 2005-01-03
Posts: 13
Website

Re: How does the <txp: /> tag work?

Aha, thanks Paul, I’m sure I can figure it out from there. One more thing, do you know how passing the functions values works? i.e <code><txp:foo attribute=“value” /></code>

Cheers :D

Last edited by koopd (2005-07-12 13:50:21)


koopd.com
seventytwo.co.uk
—-
Graphic Designer, Wed Designer and Developer.

Offline

#4 2005-07-12 17:56:29

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: How does the <txp: /> tag work?

The attribute are passed to the functions as an array after the tag brackets and structure are stripped, as $atts. The actual stripping and execution process is done by parse() and processTags() inside publish.php.

Offline

#5 2005-07-12 18:48:03

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: How does the <txp: /> tag work?

Be aware that textpattern is using preg_replace_callback. While this is nice to read, depending on what you want to do, it has drawbacks. The strongest practical issue to consider is that you are going to experience problem, when you try to nest identical tags – this can’t be really done with regexes alone.

Before you start to roll your own, you might want to look at http://www.phpwact.org/ or http://phptal.motion-twin.com/ which also have tag-based templates, though differ considerably in other parts.

Offline

Board footer

Powered by FluxBB