Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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

#2 2011-01-24 08:27:49

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

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&amp;context=image&amp;p=3"><img src="http://www.mysite.com/blog/images/3t.jpg" alt="" /></a>

Offline

#4 2011-01-24 10:50:18

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

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

#6 2011-01-24 13:06:03

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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

Board footer

Powered by FluxBB