I want to call a function of a component present in plugin. In my app/xyz_controller i include it as follows var $components = array('Plugin_name.Component_name'); And i call a function as- $this->Component_name->xyz(); But it doesnot work. Can any body help me where is the problem?
2 Answers
Not sure if this was just your example, but you should refer to plugins and components using camel case instead of underscores:
$components = array('PluginName.ComponentName');
$this->ComponentName->xyz();
This seems to work for me - I am running using Cake 1.3.
1 Comment
mark
Way better than the other answer :)
Have you tried requestAction?, perhaps you could use something like
$this->requestAction('/Plugin_name/Component_name/xyz');
you can get more information about requestAction at the online documentation
3 Comments
Abba Bryant
He isn't trying to load an action. He is trying to call a component function. RequestAction won't do that for him.
Abba Bryant
because requestAction can call controller actions but not call controller's component functions. That is the difference.