views:

119

answers:

2

im developing a web application, using multiple pages, each with their own controller.

The problem now is that there are some variables in a controller, created for one page, that are required for an other page ( with a different controller).

Therefor i need to load one controller into the other one.

I did this by adding App::import('Controller', 'sections');

$sections= new sectionsController; $sections->constructClasses();

to the controller, but this doens't seem to work..

Maybe u guys have some ideas?

Thnx in advance!

A: 

You can use any one of the methods below to access a variable anywhere in the cakePHP application.
1.) use the configuration class OR
2.) use session for those variables

Gaurav Sharma
Sorry, but i that doesn't seem to work aswell..
john
+1  A: 

I think there're some misunderstandings in your mind about MVC architectural pattern.If you need some bullet for your gun,just get the bullet itself,and it's not neccessary to get another gun with it.So I hope you understand loading controller is really a bad idea.

Also if you want some variables accessable by all controllers,as Gaurav Sharma mentioned ,you can use Configure::write() to store data in the application’s configuration app/config/core.php.e.g

Configure::write('somekey',$someval);

Then you can get $someval by Configure::read('somekey') in any controller.

SpawnCxy