Feng Forum

Other Topics => Development => : Kasuo August 05, 2010, 10:31:31 AM

: hook and interface
: Kasuo August 05, 2010, 10:31:31 AM
Hello,
I would like to change the interface "add task" using a hook.
I am a new développer and I don t know how to use it.
What is the easiest way to add something to an interface using a hook: to load an other view or to add directly something inside.
I saw an exemple where somebody used an override of setLayout but I don t know how to overide setTemplate for a view.
Thank you.
: Re: hook and interface
: alvarotm01 August 05, 2010, 06:36:31 PM
To override a view you can use the "after_action" hook.
Here is an example:
:
Hook::register("your_hook_name");

function your_hook_name_after_action($args, &$ret) {
$controller = array_var($args, 'controller');
$action = array_var($args, 'action');
if ($controller instanceof TaskController && $action == 'add_task') {
$controller->setTemplate('new_add_task');
}
}

Here for the action "add_task" the template will be overriden by the new php file "new_add_task.php" which must be located in the folder "application/views/task/".

For more information about the available hooks and its specification you can look at the file "application/hooks/opengoo_hooks.php".

regards
: Re: hook and interface
: Kasuo August 06, 2010, 06:08:31 AM
Thank you,
An other question, what is the best practice to change a ".js" interface
(public\asset\javascript\og\task\addTask.js).
I would like to change it (to see a custum property in the quick edit menu).
Is that possible (a custum property need php normaly ) ?