确保Drupal模块中的钩子在其他钩子之前运行。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了确保Drupal模块中的钩子在其他钩子之前运行。相关的知识,希望对你有一定的参考价值。
Sets a module's weight to the lowest number. This assures that your module is ran before all other modules. Userfull if you want your implementation of a hook to be ran first.Add this to your .install file. Replace your_modulename with the name of your module.
function your_modulename_install() { switch ($GLOBALS['db_type']) { case 'mysqli': $weight = db_result(db_query('SELECT MIN(weight) AS weight FROM {system} WHERE status = 1')) - 1; db_query("UPDATE {system} SET weight = %d WHERE name = '%s'", $weight, 'your_modulename'); break; default: drupal_set_message(t('Your database type is not supported')); } }
以上是关于确保Drupal模块中的钩子在其他钩子之前运行。的主要内容,如果未能解决你的问题,请参考以下文章
Drupal 8添加javascript并使用自定义模块在钩子中传递数据