函数地址:hook_preprocess_HOOK
1 首先解释下hook_preprocess_HOOK这个钩子的含义:
hook
_ preprocess _ HOOK
[module]
_ preprocess _ [theme hook name]
自定义的模块名字 预处理 通过hook_theme 声明的主题
2 使用
<?php //设置变量 function custommodule_preprocess_custom_theme_name(&$variables) { // Add a custom variables $variables['custom_var'] = 'i am a custom variable'; } //在你的主题模版中使用变量 echo $custom_var; 或者 echo $variables['custom_var']; ?>
notice
【theme
hook name】使用 函数(theme_get_registry()) 查看当前系统中有多少注册的主题
3 举例
custom_module_name_preprocess_node
custom_module_name_preprocess_breadcrumb
custom_module_name_preprocess_page
custom_module_name_preprocess_comment
相同功能的函数: hook_process_HOOK
drupal7 使用(hook_preprocess_HOOK)向各个主题模版里面传递变量,布布扣,bubuko.com
时间: 2024-12-29 11:19:51