是否可以在一個模塊內聲明和管理多個自定義內容類型?我正在創建一個需要四種自定義內容類型的網站,我想從一個模塊來管理它們,而不是爲每種內容類型創建模塊。經過一些測試後,我發現這似乎是不可能的。因爲,除非hook_form和內容類型共享相同的模塊名稱,否則drupal不會調用hook_form。從一個模塊管理多個自定義內容類型(drupal)
這裏就是我想要做的 -
function mycontent_node_info(){
return array(
'mycontent1' => array(
'name' => t('....'),
'module' => 'mycontent',
'description' => t('...),
'has_title' => TRUE,
'title_label' => t('Title'),
'has_body' => TRUE,
'body_label' => t('content body'),
),
'mycontent2' => array(
.......
),
'mycontent3' => array(
......
),
'mycontent4' => array(
......
),
);
}
function mycontent1_form(&$node){
$form['control1'] = array(
'#type' => 'select',
'#options' => array(
'0' => t('selection 1'),
'1' => t('selection 2'),
),
'#attributes' => array('id'=>'control1'),
);
$form['control2'] = array(
'#type' => 'select',
'#options' => array(
'0' => t('1'),
'1' => t('2'),
'2' => t('3'),
'3' => t('4'),
),
'#attributes' => array('id'=>'control2'),
);
return $form;
}
function mycontent2_form(&$node){
....
}
function mycontent3_form(&$node){
....
}
function mycontent4_form(&$node){
....
}
難道我在這裏做得不對或者是不可能的,還有比每一個內容類型創建模塊,沒辦法等。我非常感謝你的幫助。
對不起,我遲到的答覆。感謝它的工作。 – Andrew 2010-06-09 17:56:48