• <tfoot id='kzu0K'></tfoot>
      <bdo id='kzu0K'></bdo><ul id='kzu0K'></ul>

    1. <legend id='kzu0K'><style id='kzu0K'><dir id='kzu0K'><q id='kzu0K'></q></dir></style></legend>

      <small id='kzu0K'></small><noframes id='kzu0K'>

        <i id='kzu0K'><tr id='kzu0K'><dt id='kzu0K'><q id='kzu0K'><span id='kzu0K'><b id='kzu0K'><form id='kzu0K'><ins id='kzu0K'></ins><ul id='kzu0K'></ul><sub id='kzu0K'></sub></form><legend id='kzu0K'></legend><bdo id='kzu0K'><pre id='kzu0K'><center id='kzu0K'></center></pre></bdo></b><th id='kzu0K'></th></span></q></dt></tr></i><div id='kzu0K'><tfoot id='kzu0K'></tfoot><dl id='kzu0K'><fieldset id='kzu0K'></fieldset></dl></div>
      1. 如何在 drupal 7 中实现 hook_theme?

        How to implement hook_theme in drupal 7?(如何在 drupal 7 中实现 hook_theme?)
        <i id='iE8o6'><tr id='iE8o6'><dt id='iE8o6'><q id='iE8o6'><span id='iE8o6'><b id='iE8o6'><form id='iE8o6'><ins id='iE8o6'></ins><ul id='iE8o6'></ul><sub id='iE8o6'></sub></form><legend id='iE8o6'></legend><bdo id='iE8o6'><pre id='iE8o6'><center id='iE8o6'></center></pre></bdo></b><th id='iE8o6'></th></span></q></dt></tr></i><div id='iE8o6'><tfoot id='iE8o6'></tfoot><dl id='iE8o6'><fieldset id='iE8o6'></fieldset></dl></div>
        <tfoot id='iE8o6'></tfoot>

            <small id='iE8o6'></small><noframes id='iE8o6'>

              <tbody id='iE8o6'></tbody>
              • <bdo id='iE8o6'></bdo><ul id='iE8o6'></ul>
                • <legend id='iE8o6'><style id='iE8o6'><dir id='iE8o6'><q id='iE8o6'></q></dir></style></legend>
                  本文介绍了如何在 drupal 7 中实现 hook_theme?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我创建了一个新的 drupal 7 主题并尝试在 template.php 中实现 hook_theme,如下所示:

                  I created a new drupal 7 theme and trying to implement hook_theme at template.php like this:

                  function mytheme_theme($existing, $type, $theme, $path){
                      return array(
                          'mytheme_header'=>array(
                              'template'=>'header',
                              'path'=>$path.'/templates',
                              'type'=>'theme',
                          ),
                      );
                  }
                  

                  然后我把header.tpl.php放入templates目录并清除所有缓存,并调用主题函数:

                  then I placed header.tpl.php into templates directory and cleared all caches, and call theme function:

                  theme('mytheme_header', $vars);
                  

                  和 header.tpl.php 喜欢这个:

                  and header.tpl.php likes this:

                  <?php
                  fb('calling header template');//the function of FirePHP to output debug info
                  print '<div>Header</div>';
                  //...
                  

                  我检查了 Firebug,它得到信息调用标题模板",这意味着它调用了 header.tpl.php,但它没有打印 html 代码.我的代码有什么问题?

                  I check Firebug and it get the info 'calling header template', it mean it had called header.tpl.php, but it didn't print the html code. What's wrong with my code?

                  推荐答案

                  尝试在hook_theme

                  function mytheme_theme($existing, $type, $theme, $path){
                      return array(
                          'mytheme_header' => array(
                              'template' => 'header',
                              'path' => $path . '/templates',
                              'type' => 'theme',
                              'variables' => array(
                                  'title' => NULL,
                                  'some_text' => NULL,
                              ),
                          ),
                      );
                  }
                  

                  在您的 header.tpl.php 文件中:

                  <h1><?php print $title; ?></h1>
                  <p><?php print $some_text; ?></p>
                  

                  然后,像这样打印出来:

                  Then, print it out like this:

                  $vars = array();
                  $vars['title'] = "This is a title";
                  $vars['some_text'] = "Some text...";
                  print theme('mytheme_header', $vars);
                  

                  这篇关于如何在 drupal 7 中实现 hook_theme?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  <small id='m6i1s'></small><noframes id='m6i1s'>

                    <bdo id='m6i1s'></bdo><ul id='m6i1s'></ul>

                        <tfoot id='m6i1s'></tfoot>

                        <legend id='m6i1s'><style id='m6i1s'><dir id='m6i1s'><q id='m6i1s'></q></dir></style></legend>
                          <i id='m6i1s'><tr id='m6i1s'><dt id='m6i1s'><q id='m6i1s'><span id='m6i1s'><b id='m6i1s'><form id='m6i1s'><ins id='m6i1s'></ins><ul id='m6i1s'></ul><sub id='m6i1s'></sub></form><legend id='m6i1s'></legend><bdo id='m6i1s'><pre id='m6i1s'><center id='m6i1s'></center></pre></bdo></b><th id='m6i1s'></th></span></q></dt></tr></i><div id='m6i1s'><tfoot id='m6i1s'></tfoot><dl id='m6i1s'><fieldset id='m6i1s'></fieldset></dl></div>
                              <tbody id='m6i1s'></tbody>