Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

hooks not working please check

edited July 2017 in Modules
hi
I want to check dependency from other table entry of an module before deleting its entry ..
so if their is no entry for this module exists it allow it to delete else cant be deleted

i have done following things :
model name : Jobs_model

config->hooks.php

$hook['before_delete_jobs'] = array(
'class' => 'job_hooks',
'function' => 'before_delete_jobs',
'filename' => 'Job_hooks.php',
'filepath' => 'hooks',
'params' => array(),
'module' => 'job');
hooks -> Job_hooks.php

class Job_hooks extends CI_Controller {
public function __construct()
{
parent::__construct(); // table name
}
function before_delete_jobs($where)
{
print_r($where); return FALSE;die(); //just to prevent from getting deleted implement the thing later
}

}
but the function did not executing or if executed have no effect
is their any mistake ??? or have other simple way please check

Comments

  • edited 12:09PM
    The "module" parameter in the hook is actually referencing an advanced module folder name (which is a little confusing). Do you have an advanced module in the "fuel/modules/job" folder? If not and it's in your fuel/application folder, remove the "module" parameter on the hook or change it to "app" and see if that fixes your issue.
  • edited 12:09PM
    i have removed the module parameter those it is still not working ...
    instead on my Jobs_model
    "on_before_delete" function is working
    public function on_before_delete($values)
    {
    print_r($values);
    //die();
    return FALSE;
    }
    but if i remove the die statement it is still removing the entry .. is their a way to stop it
    instead of redirecting it .
  • edited 12:09PM
    What is the path to the Job_hooks.php file? Also, the Job_hooks.php file shouldn't be on a controller but exist in it's own class file similar to the fuel/modules/fuel/hooks/Fuel_hooks.php file which is based on the native CI hooks:
    https://codeigniter.com/user_guide/general/hooks.html
  • edited 12:09PM
    that is in application->hooks folder
  • edited 12:09PM
    What does your class look like now to execute the fuel/application/hooks/Jobs_hooks::before_delete_jobs method? Also, is your fuel/application/config/hooks.php configuration set to the following and you have a module of "jobs" set in your fuel/application/config/MY_fuel_modules.php:
    $hook['before_delete_jobs'] = array( 'class' => 'Job_hooks', 'function' => 'before_delete_jobs', 'filename' => 'Job_hooks.php', 'filepath' => 'hooks', 'params' => array() );
Sign In or Register to comment.