cakePHP - how do I conditionally load a component into a controller? -
I am using the great Facebook plugin for CakePeP 1.3 I currently have this:
class UsersController Extends AppController {var $ name = 'Users'; Var $ components = array ('Facebook.Connect'); Failure before function {$ this- & gt; Set ('facebookUser', $ this-> Connect-> User ()); }}
but I want to load Facebook. Use the connector conditionally, and use it in the controller - in some such codec ...
if ($ this istru) {Load_the_component_and_make_it_ready_for_use; $ This- & gt; Set ('facebookUser', $ this-> Connect-> User ()); }
How should I do this?
is triggered when loading with the controller after the component I load it later Do not recommend.
Like Maggie you have commented that you can load the component (but) you have to call the startup and have to initialize it and attach the object to your controller
Everything in it can be just $ -> easy to set up ... is conditional and load components every time.
Comments
Post a Comment