Just use the beforeRender() method at AppControler, which should be the
base of your controllers.

So for example you have app_controller.php on your app/ directory:

class AppController extends Controller {
     function beforeRender() {
          $data = array (
               'message' => 'Hello World!';
          );

          $this->set('data', $data);
     }
}

Then you have your controllers extend AppController. For example, you
can have app/controllers/test_controller.php:

class TestController extends AppController {
     function index() {
          // Do nothing
     }
}

And also

 app/controllers/another_test_controller.php:

class AnotherTestController extends AppController {
     function index() {
          $this->set('extra', 'Extra Message');
     }
}


Then the app/views/test/index.thtml:

And the message is: <?php echo $data['message']; ?>

And the app/views/another_test/index.thtml:

And the message is: <?php echo $data['message']; ?> with some extra
message: <?php echo $extra; ?>

Remember the MVC separation logic. Data should be passed on TO the
view, and the view SHOULD NOT fetch data by itself.

-MI


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to