drupal 7自定义内容hook_theme输出 [英] drupal 7 custom content hook_theme output
问题描述
但它不工作,我做错了什么?
<?php
/ **
*实现hook_block_info()。
* /
function submenus_block_info(){
$ blocks = array();
$ blocks ['info'] = array(
'info'=> t('子菜单区')
);
return $ blocks;
}
/ **
*实现hook_block_view()。
*
* /
函数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;
}
/ **
*实现hook_theme()
* /
函数submenus_theme(){
返回数组(
'submenus_output'=> array(
'variables'=> array('users'=> NULL,'title'=> NULL),
),
);
}
/ **
*显示输出
* /
function theme_submenus_output($ somearray){
$ content ='< DIV> TEST< / DIV>';
return $ content;
}
?>
我检查过,代码没有错误:新块在块列表中可用,并且如果将其分配给某个区域,则会调用该块并显示自定义主题功能中的代码。
所以你可以试试这些东西:
-
在
管理>配置>发展>执行
,清除管理>中的缓存
-
结构>阻止,确保块已分配给存在的区域(例如内容),如果是,请单击
配置
链接,看看是否有一个过滤器阻止它显示。
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.
So you could try these things:
in
Administration > Configuration > Development > Performance
, clear the cachesin
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屋!