Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Straight variable setting and replacement?
I’m trying to do some things where the same variable is repeeated over and over, but it seems that there are no generic variables available in TXP, only ones for each tag.
Is there any way to do something like this:
var1=whopper
<a href=“http://$var1.com>$var1</a>
<img src=”$var1.jpg” class=”$var1”>
without raw php?
Actually what i’d love to be able to do is
<txp output_form form=“code_with_vars” var1=“whopper”> where $var1 will then be replaced throughout the called form, so I can call a single form a number of times and get different output.
Offline
Re: Straight variable setting and replacement?
Hmm, I wonder what you’re trying to archieve with that. But why not using some of these:
txp:output_form
txp:custom_field
like:
<a href="http://<txp:custom_field name="custom1" />.com"><txp:custom_field name="custom1" /></a>
<img src="<txp:custom_field name="custom1" />" alt="" class="<txp:custom_field name="custom1" />" />
Or it could be easily done with php’s strtr.
<txp:php>
$tags = array(
'var1' => 'mytag',
'var2' => 'mytag2',
);
echo strtr('Your content here - were var1 is mytag',$tags);
</txp:php>
Cheers!
Offline