Using drupal7 (hook_preprocess_hook) to pass variables to each topic Template

Source: Internet
Author: User
Function address: hook_preprocess_hook


1 first explain the meaning of the hook_preprocess_hook HOOK:


Hook _ preprocess _ hook

[Module] _ preprocess _ [Theme hook name]


The custom Module name pre-processes the theme declared through hook_theme


2. Use

<? PHP // set the variable function custommodule_preprocess_custom_theme_name (& $ variables) {// Add a custom variables $ variables ['m M _ var'] = 'I am a custom variable ';} // use the echo $ custom_var variable in your topic template; or ECHO $ variables ['m M _ var'];?>

Notice

[Theme hook name] use the function (theme_get_registry () to check the number of registered topics in the current system.


3. Example

Custom_module_name_preprocess_node

Custom_module_name_preprocess_breadcrumb

Custom_module_name_preprocess_page

Custom_module_name_preprocess_comment


Functions of the same function: hook_process_hook

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.