我尝试将新选项卡添加到特定内容类型'abc',这是代码,但它不起作用,选项卡显示在所有节点上.任何人都可以帮忙吗?谢谢!
function addtabexample_menu() {
$items=array();
$items['node/%node/test'] = array(
'title' => 'Test',
'page callback' => 'handle_test',
'page arguments' => array('node', 1),
'access arguments' => array('access content'),
'type' => MENU_LOCAL_TASK,
'weight' => 100,
);
return $items;
}
function handle_test($node){
$result='hi';
if ($node->type == 'abc') {
$result='I am working';
}
Run Code Online (Sandbox Code Playgroud) 我需要在Drupal 7中向节点添加一个程序化表单.如何将表单附加到节点?
function addtabexample_form($node, &$form_state) {
$type = node_type_get_type($node);
$form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#default_value' => !empty($node->title) ? $node->title : '',
'#required' => TRUE,
'#weight' => -5,
);
$form['field1'] = array(
'#type' => 'textfield',
'#title' => t('Custom field'),
'#default_value' => $node->field1,
'#maxlength' => 127,
);
return $form;
}
Run Code Online (Sandbox Code Playgroud)