PDA

View Full Version : Best Practice for PHP loaded in different panels



draklava
6 Apr 2007, 7:34 AM
I have a basic layout (center, east, south) and when I click on a tab in the center ContentPanel, I load some php pages in the center, east and south via an UpdateManager update call.

This works well but what I'm trying to figure out is the best way to pass PHP variables between the page fragments.

For example - when I click on Tab A....
center loads center.php (dynamic via UpdateManager update)
east loads east.php (dynamic via UpdateManager update)
south loads south.php (dynamic via UpdateManager update)

I have an php object in center.php and want to access it from east.php. I can have both center and east include a global.php and then see the same instance of object but was wondering if there is a better way to do this.

Arikon
9 Apr 2007, 1:42 AM
Please, don't mix up client side and server side runtime.
PHP is a server side script language and it doesn't correlise with Ext's BorderLayout at all.
That's why you can't "pass PHP variables between the page fragments".

As for PHP, you can't get access from one script instance to another script's instance objects in realtime. You can save objects to session in one script instance, and get it from session in another script instance.

brian.moeskau
9 Apr 2007, 3:17 AM
Assuming that you're not talking about server-side objects, but instead client-side JavaScript objects rendered out to the page by your php pages, then yes, you can access them across panels assuming you have your scope set up correctly and that things are rendered when you expect them to be. Not sure if that's what you're asking though.

draklava
10 Apr 2007, 6:35 AM
Arikon is correct about what I'm trying to do. I realize that the php part is executed on the server but I have different PHP pages being loaded dynamically by the client so I need to have them looking at the same object in memory.

I think serializing to the session is what I'm looking for. It also works to have both pages refer to a global php variable but I think I'll put it in the session to keep it clean.

thanks

newt
23 Jun 2007, 12:47 PM
Sup! I just ran across this in a browse.

Actually passing PHP variables between php pages and even EXT javascript fragments in other panels is quite easy. As long as you remember to refresh your panels onchange where needed.

Make sure all your pages including the EXT container page are .php pages, put the variables in a php session object or in your internal app session object if you have one. Start or include the session in your EXT container page, then refresh onchange.

You can also do javascript echo substitution to talk to EXT directly from php. In essence when you do a refresh onchange, have php echo out the javascript you want, such as a value for a javascript variable or any other javascript code change needed. And it will be immediately available to EXT.

Hope this helps!

-N