Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-11-29 21:08:06

tennapel
Member
Registered: 2009-05-31
Posts: 62

General question: passing variables between plugin and sections

While coding I noticed that superglobals like $_SESSION are not acting as superglobals in Textpattern. If I assign a value to a $_SESSION array, that array value is available within the section you embed the plug-in tag in, but not in other sections.

If you put

<txp:pgp>session_start(); global $_SESSION</txp:php>

at the top of each template, the $_SESSION is available in all sections.

There must be a (security) reason why superglobals act as they do in textpattern, so what is the best method to pass variables between a plugin and a section and in between sections? I cannot find any documentation about this subject.

Last edited by tennapel (2009-11-29 21:08:18)

Offline

#2 2009-12-01 08:36:24

tennapel
Member
Registered: 2009-05-31
Posts: 62

Re: General question: passing variables between plugin and sections

No plugin authors who ever had to work with the same issue? I find that hard to believe…

Offline

#3 2009-12-01 09:42:52

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: General question: passing variables between plugin and sections

I think this is a result of eval() the plugin code. So you have to declare your global variables explititly.

See Ruuds answer for similar problem here: http://forum.textpattern.com/viewtopic.php?id=31364.

Last edited by trenc (2009-12-01 09:43:32)


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

Board footer

Powered by FluxBB