Author Topic: hook and interface  (Read 3769 times)

Kasuo

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
hook and interface
« on: 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.

alvarotm01

  • Administrator
  • Sr. Member
  • *****
  • Posts: 335
    • View Profile
    • Email
Re: hook and interface
« Reply #1 on: August 05, 2010, 06:36:31 pm »
To override a view you can use the "after_action" hook.
Here is an example:
Code: [Select]
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

Kasuo

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: hook and interface
« Reply #2 on: 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 ) ?