Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-11-08 03:52:53

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

<txp:php> in form // syntax

Can I set a variable from a form?

I’m trying to achieve this: $default = ‘artists’;

But when I wrap it in the txp:php tags inside my form nothing happens.
When I test for the variable, it’s empty

Any help would be appreciated.

Thanks,
Tom

Last edited by renobird (2005-11-08 03:55:26)

Offline

#2 2005-11-08 05:04:01

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: <txp:php> in form // syntax

You have to declare the variable global for each instance of the php tag you want to use it in, both when you define it, and when you call it.
<txp:php>global $default; $default = 'artists';</txp:php>
<txp:php>global $default; echo $default;</txp:php>

Offline

#3 2005-11-09 16:48:26

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: <txp:php> in form // syntax

Hi Mary,

Thanks. That got things working…sort of. I’m working on a site that was set up a long time ago and is running TXP on some non-TXP pages. The variable is not getting sent to the page that is outside of TXP. Is there a way to do that?

Thanks for the help.

)

Tom

Offline

#4 2005-11-09 22:50:33

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: <txp:php> in form // syntax

It sounds like you’re running a heavily customized installation. The problem is in the design of your system, which means you’re pretty much on your own, since nobody here knows anything about how you’ve set it up.


Alex

Offline

#5 2005-11-10 00:54:46

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: <txp:php> in form // syntax

Hi Zem,

Yeah…it’s something I inherited this way. I’m going to gradually update everything.
I know I’m pretty much on my own with it set up this way…I’m just attempting to implement a few things for this site, and then I’ll have some breathing room to set it up properly.

I would still appreciate any help if you’re willing…I think it’s probably something simple I’m overlooking.

Simple version:
1. PHP variable set in a txp form – just as Mary described above
2. form output to a non-txp page
3. value doesn’t seem to get passed to the non-txp page…a simple echo returns nothing.

Thanks so much for the time…I’ll eventually get everything moved back into Textpattern.

Cheers,
Tom

Offline

#6 2005-11-10 01:25:33

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: <txp:php> in form // syntax

Like I said, everything depends on how the system is designed. There’s nothing special about the way PHP code in Textpattern sets variables, other than the fact that you have to explicitly make them global if that’s what you need.


Alex

Offline

Board footer

Powered by FluxBB