Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-08-14 17:55:25

nemozob
Member
Registered: 2008-04-15
Posts: 36

Replacing value with variable -- is this possible?

Inside an article tag I would like to do the following replacement (obviously bad code but you get the idea):

$foo = <txp:custom_field name="people" />
<txp:article_custom id="$foo" form="eventPeopleOutput" />

Is there a way to do this?

What I’m trying to do is first output a parent article. This parent article has a custom field value which contains a number. This number refers to the ID of an article I want to output (via the article_custom tag). But I haven’t figured out a way to pass that $foo variable.

Last edited by ruud (2008-08-14 19:10:30)

Offline

#2 2008-08-14 18:23:45

nemozob
Member
Registered: 2008-04-15
Posts: 36

Re: Replacing value with variable -- is this possible?

Answering own question, though perhaps there’s a better way…

<txp:php>
$authorname = custom_field (array('name' => 'people',));
echo '<txp:article_custom id="'.$authorname.'" form="eventPeopleOutput" />';
</txp:php>

Last edited by ruud (2008-08-14 19:10:17)

Offline

#3 2008-08-14 19:09:13

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

Re: Replacing value with variable -- is this possible?

TXP 4.0.6 and lower:

<txp:php>
  $authorname = custom_field(array('name' => 'people'));
  echo article_custom(array('id' => $authorname, 'form' => 'eventPeopleOutput' />;
</txp:php>

TXP 4.0.7 (not yet released) and higher

<txp:article_custom id='<txp:custom_field name="people" />' form="eventPeopleOutput" />

Offline

#4 2008-08-14 19:22:04

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: Replacing value with variable -- is this possible?

If I understand it correctly you can achieve this with TXP 4.0.6 and lower also using plugin asy_wondertag:

<txp:asy_wondertag>
<txp:article_custom id="<txp:custom_field name="people" />" form="eventPeopleOutput" />
</txp:asy_wondertag>

Offline

Board footer

Powered by FluxBB