Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2011-01-24 06:22:04
- jpdupont
- Member
- Registered: 2004-10-01
- Posts: 752
Textpattern Tag to corresponding PHP function
Hello !
I know each txp or plugin tag correspond to a php function.
example :
$img_url = image_url(array ('id' => $id));
$thumb_url = smd_thumbnail(array ('id' => $id,
'type'=>$type,'class'=>$thumb_class));
//build some strings with the variables ...
Question : How “translate” a txp as container tag in PHP, like this :
<txp:images category="test">
<txp:image_info type="id" /><br/>
</txp:images>
Offline
Re: Textpattern Tag to corresponding PHP function
$foo = images(array('category' => 'test'), image_info(array('type' => 'id')) );
Offline
#3 2011-01-24 09:58:59
- jpdupont
- Member
- Registered: 2004-10-01
- Posts: 752
Re: Textpattern Tag to corresponding PHP function
Thanks but don’t work.
$img = images(array('category' => $category), image_info(array('type' => 'id')) );
returm the same as what I try before :
$img = images(array ('category' => $category));
Something like this for each image :
<a href="http://www.mysite.com/blog/articles/?c=_body-background&context=image&p=3"><img src="http://www.mysite.com/blog/images/3t.jpg" alt="" /></a>
Offline
Re: Textpattern Tag to corresponding PHP function
Um. My mistake:
$foo = images(array('category' => 'test'), '<txp:image_info type="id" /><br/>' );
or
$foo = parse('
<txp:images category="test">
<txp:image_info type="id" /><br/>
</txp:images>
');
Offline
#5 2011-01-24 12:17:43
- jpdupont
- Member
- Registered: 2004-10-01
- Posts: 752
Re: Textpattern Tag to corresponding PHP function
Thanks Ruud,
I try the
$foo = images(array('category' => 'test'), '<txp:image_info type="id" /><br/>' );
with success.
So we must pass as second parameter all the stuff in the container, as it …
Offline
Re: Textpattern Tag to corresponding PHP function
jpdupont wrote:
So we must pass as second parameter all the stuff in the container, as it …
Yes, for container tags the second parameter ($thing
) is the contained code. Usually the container tag will call the parser, and parses the tagnest. TXP mainly uses globals to transfer data from one scope to other (from container to child tags), and the globals are not set if the function is called outside the container, thus the tagnest as the $thing.
Last edited by Gocom (2011-01-24 13:15:43)
Offline