[英]Drupal & custom module using page_build hook to add content to the sidebar
I'm trying to build a custom module that has to add a form to the sidebar_first. 我正在尝试构建一个自定义模块,该模块必须向sidebar_first添加表单。 I tried using page_build hook but that did not work.
我尝试使用page_build挂钩,但是没有用。
function module1_page_build(&$page){
drupal_set_message("Inside page builder");
$page['sidebar_first']['filters'] = array(
'#markup' => drupal_form_build('filter_formbuild',$formstate=NULL),
'#prefix' => '<div class="filters">',
'#suffix' => '</div>',
);
}
I created a function filter_formbuild which returns a form array which is something like this. 我创建了一个函数filter_formbuild,它返回一个像这样的表单数组。 function filter_formbuild(){
函数filter_formbuild(){
$form = array();
$form['title'] = array(
'#title' => 'Title',
'#type' => 'textfield',
'#size' => '100',
);
$form['url'] = array(
'#title' => 'Name',
'#type' => 'textfield',
'#size' => '100',
);
$form['notes'] = array(
'#title' => 'Notes',
'#type' => 'textarea',
'#maxlength' => 200,
'#size' => '30',
);
$form['author'] = array(
'#title' => 'Author(s)',
'#type' => 'textfield',
'#maxlength' => 30,
'#size' => '100',
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
return $form;
}
I think the hook was not initiated since the set_message was also not working. 我认为该钩子没有启动,因为set_message也无法正常工作。 Can someone suggest another way to do this or is there any errors in my implementation.
有人可以建议另一种方法来执行此操作,还是我的实现中有任何错误。 I'm new to drupal custom modules
我是drupal自定义模块的新手
/** * Implements hook_block_info(). */ function custom_block_block_info() { $blocks = array(); $blocks['my_block'] = array( 'info' => t('My Custom Block'), ); return $blocks; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.