Drupal,我在哪里可以找到页脚文件?

时间:2014-10-14 11:48:53

标签: php drupal

我需要在drupal上将一些代码放到网站上,我需要这些代码才能在我网站的每个页面上运行。我怎样才能做到这一点?我想找到页脚文件并在里面放一些代码,但我找不到它。

1 个答案:

答案 0 :(得分:3)

有三种方法可以将 PHP 代码添加到页脚中。

1>打开PHP filter&将代码输入位于页脚左侧区域的块中 2 - ;将代码放在子主题中相应的模板文件中 3 GT;创建一个模块,将代码输出到块中; 激活并放置块

假设您要在页脚区域添加以下行:

&copy;<?php print date('Y');?> Your Company Name - Address of your company.

所以最好的办法就是制作这样的小模块:

<强> copyright_block.info

name = Copyright Block
description = Shows the (incrementing) current year and company information.
package = Other
core = 7.x
files[] = copyright_block.module

<强> copyright_block.module

<?php
/**
* @file
* This module shows the copyright year and company information.
*/
/**
* Implements hook_help().
*/
function copyright_block_help($path, $arg) {
  if ($path == 'admin/help#copyright_block') {
    return t('Manually edit to change company information');
  }
}
/**
* Implements hook_block_info().
*/
function copyright_block_block_info() {
  $blocks = array();
  $blocks['show_copyright'] = array(
    'info' => t('Company Information'),
    'cache' => DRUPAL_NO_CACHE,
  );
  return $blocks;
}
/**
* Implements hook_block_view().
*/
function copyright_block_block_view($block_name = '') {
  if ($block_name == 'show_copyright') {
$content = "<p>&copy;" . date('Y') ." Your Company Name - Address of your company</p>";
    $block = array(
      'subject' => t('Company Information'),
      'content' => $content,
    );
    return $block;
  }
}

注意:请勿将 PHP结束标记 ?>放在最后。