我是 Drupal 的新手。我使用以下代码创建了一个 contace1 模块:
联系方式1.info
; $Id$
name = Contact1
description = Show how to build contact form
package = Pro Drupal Development
core = 6.x
contact1.module
// $Id$
/**
* @file
* practice to build form
*/
/**
* Implimentation of hook_menue().
*/
function contact_menu()
{
$items['contact1'] = array(
'title' => 'Contact',
'page callback' => 'contact_page',
'access argument' => array('access content'),
'type'=>MENU_CALL_BACK,
'access callback' => TRUE,
);
return $items;
}
/**
* menu callback
* called when user goes to http://localhost/drupaldemo/?q=contact
*/
function contact_page()
{
$output = t('You can leave a message using the contact form below.');
//Return the html generated from $form data structure.
$output.= drupal_get_form('contact_nameform');
return $output;
}
/**
* define the form
*/
function contact_nameform()
{
$form['user_name']= array(
'#title' =>t('Your Name'),
'#type' => 'textfield',
'#description' => t('Please enter your name.'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
) ;
return $form;
}
/**
* validate the form
**/
function contact_nameform_validate()
{
if($form_state['values']['user_name']=="")
{
form_set_error('user_name',t('Please enter your name.'));
}
}
/**
* handle post validation form submition
*/
function contact_nameform_submit($form ,&$form_state)
{
$name=$form_state['values']['user_name'];
drupal_set_message(t('Thanks for filling out the form, %name',array('%name'=>$name)));
}
我这个代码我试图创建新的联系表
但它没有显示任何链接,并且在打开页面上直接给出未找到的页面。