这是我的custom.info
name = Custom
description = Custom module
core = 7.x
package = Own
和custom.module
<?php
/**
* @file
* An example custom module for selecting, updating and deleting query
*/
/**
* Implementation of hook_block_info()
*/
echo 'Today: \n';
echo date('m/d/Y');
function custom_block_info() {
$block['custom'] = array('info' => t('Custom block'))
return $block;
}
/**
* Implements hook_block_view.
*/
function custom_block_view($delta = '') {
global $user;
$block['content'] = t('Hello @user from IP @host',array(
'@user' => format_username($user),
'@host' => $user->hostname`enter code here`
));
$result = db_select('node','a')
->fields('a', array('title'))
->execute();
foreach($result as $node) {
$items[] = array(
'data' => t($node->title)
);
}
$block['content'] .= theme('item_list', array(
'items' => $items
));
return $block;
}
但是这个自定义模块没有在我放置块的侧边栏中显示数据。我把echo语句放在代码之上它甚至没有显示块中的echo语句可以任何人告诉我如何解决这个问题????
P.S。我安装了drupal我在数据库中没有改变任何东西!
答案 0 :(得分:1)
检查模块列表(admin / modules)中的模块是否处于活动状态,如果是这样,请尝试将echo语句放在hook_init中,如下所示:
function custom_init(){
echo 'Today: \n';
echo date('m/d/Y');
}
然后清除所有drupal缓存配置&gt;表现&gt;清除alla缓存 (admin / config / development / performance)