Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
<txp:php> and javascript
Usually you can place some php in javascript, such as to echo a variable, without much hassle.
But <txp:php> always causes a syntax error for me.
Can it be done? Am I doing it wrong?
Update: solved
For anyone reading this in the future.
Putting global before the $variable in the javascript is what fixed it.
Last edited by amordecosmos (Today 01:24:08)
Offline
Re: <txp:php> and javascript
amordecosmos wrote #340456:
Putting global before the $variable in the javascript is what fixed it.
Glad it’s solved, but, to make things more future-proof, you can (in 4.9?) inject values this way:
<txp:php my_var='<txp:variable name="my_var" />'>
echo $my_var; //or whatever
</txp:php>
Offline
Pages: 1