Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-03-27 19:30:14

mattgilbert
Member
Registered: 2006-03-23
Posts: 70

txp:php to GET variables and pass them as attributes a txp tag

I’m trying to use txp:php to grab a GET variable, like so:
<code><txp:php>echo $_GET[“some_var”];</txp:php></code>

That works fine for writing directly into the html, but what I would like to do is pass that variable to another txp tag, so something like:
<code><txp:some_tag some_att=<txp:php>echo $_GET[“some_var”];</txp:php> /></code>

That didn’t work, and neither does:
<code><txp:some_tag some_att=’<txp:php>echo $_GET[“some_var”];</txp:php>’ /></code>
or
<code><txp:some_tag some_att=”<txp:php>echo $_GET[‘some_var’];</txp:php>” /></code>

Is there a way to do this?

Offline

#2 2006-03-27 20:06:19

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: txp:php to GET variables and pass them as attributes a txp tag

I don’t believe so; parse() will parse php that is contained in the tag’s contents, but not in an attribute.

  • Yes:
    • <txp:some_tag><txp:php>echo 'foo';</txp:php></txp:some_tag>
  • No:
    • <txp:some_tag att="<txp:php>echo 'foo';</txp:php>" />

Do you have a specific example case?

Last edited by Andrew (2006-03-27 20:07:58)

Offline

#3 2006-03-27 20:23:18

mattgilbert
Member
Registered: 2006-03-23
Posts: 70

Re: txp:php to GET variables and pass them as attributes a txp tag

Thanks a lot Andrew.

The tag that I wanted to pass the attribute to was in a plug-in, so I found a work-around by opening up the plug-in and just GETting the variable from in there. It’s sort of an obvious solution, but I probably wouldn’t have tried it without your explanation, so thanks a lot!

Offline

Board footer

Powered by FluxBB