drupal 7 自定义内容 hook_theme 输出 [英] drupal 7 custom content hook_theme output
问题描述
我在 Drupal 7 中创建了一个自定义模块,我希望它显示一些 HTML 内容.这就是我的做法.
I have a custom module created in Drupal 7 and I want it to display some HTML content. Here is how I have did.
但它不起作用,我做错了什么?
But it is not working, what I do wrong?
<?php
/**
* Implements hook_block_info().
*/
function submenus_block_info() {
$blocks = array();
$blocks['info'] = array(
'info' => t('The submenu zone')
);
return $blocks;
}
/**
* Implements hook_block_view().
*
*/
function submenus_block_view($delta = '') {
$block = array();
$users = "edf";
$title = "sdfsd";
$block['subject'] = t('Submenu');
$block['content'] = theme('submenus_output', array('users' => $users, 'title' => $title));
return $block;
}
/**
* Implement hook_theme()
*/
function submenus_theme() {
return array(
'submenus_output' => array(
'variables' => array('users' => NULL, 'title' => NULL),
),
);
}
/**
* Display output
*/
function theme_submenus_output($somearray) {
$content = '<div>TEST</div>';
return $content;
}
?>
推荐答案
我查了一下,这段代码没有问题:新块在块列表中可用,如果你把它分配给一个区域,块被调用并显示来自自定义主题函数的代码.
I checked, there is nothing wrong with that code: the new block is available in the list of blocks, and if you assign it to a region, the block is called and the code from the custom theme function is displayed.
所以你可以试试这些:
在
管理>配置>发展>性能
,清除缓存
在管理>结构>块
,确保该块分配给一个存在的区域(例如内容"),如果是,请单击配置
"链接查看是否有过滤器阻止它被显示.
in Administration > Structure > Blocks
, make sure the block is assigned to a region that exists (such as "Content") and if it is, click the "Configure
" link to see if there is a filter that prevents it from being displayed.
这篇关于drupal 7 自定义内容 hook_theme 输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!