/**
* Implementation of hook_menu().
*/
function addons_menu() {
$items['admin/links/usercontent'] = array(
'title' => 'User page banner',
'description' => 'Configure default image for user page.',
'page callback' => 'drupal_get_form',
'page arguments' => array('user_page_content'),
'access arguments' => array('user page banner'),
);
return $items;
}
/**
* Implementation of hook_perm
*/
function addons_perm() {
return array('user page banner');
}
/**
* User page banner section
* @return <type>
*/
function user_page_content() {
$form['user_page'] = array(
'#type' => 'fieldset',
'#title' => t('Welcome, User page content'),
'#description' => t('Customize your user page content.')
);
$form['user_page']['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#size' => 50,'#weight' => 1, '#required' => TRUE, '#default_value' => $imgDetails->hp_title, '#description'=>'Type here to display the title for image or flash');
$form['user_page']['submit'] = array('#type' => 'submit', '#value' => "Submit", '#weight' => 7);
$form['user_page']['cancel'] = array('#value' => l('Cancel', 'admin/links/homecontent'), '#weight' => 8);
$form['#attributes'] = array('enctype' => "multipart/form-data");
/*
* do the relevant code to list the inserted records
* here one by one..
//$getQry = db_query("SELECT * FROM ..");
//$cnt=0;
//if (db_affected_rows($getQry) > 0) {
//while($homeObj = db_fetch_object($getQry)) {
//$cnt++;
//$rows[] = array(array('data'=>$cnt, 'width'=>'10%'), array('data'=>$homeObj->hp_title, 'width'=>'20%'), array('data'=>l('Edit', 'admin/links/homecontent/edit/'.$homeObj->hp_id).' / '.l('Delete', 'admin/links/homecontent/delete/'.$homeObj->hp_id), 'width'=>'20%'));
//}
//}
//else {
//$rows[] = array(array('data'=>"No Records Found!", 'colspan'=>3, 'align'=>'center'));
//}
*
* */
$headers = array("S.No", "Banner Title", "Actions");
$result = theme('table', $headers, $rows, array('width'=>'100%'));
$form['user_page']['report'] = array('#value' => $result, '#weight' => 12);
return $form;
}
/**
* user_page_content_validation()
* @param <type> $form
* @param <type> $form_state
*/
function user_page_content_validate ($form, &$form_state) {
$form_data = $form_state['values'];
if (!$form_data['title']){
form_set_error('', 'Please enter the banner title!');
}
}
/**
*
* @param <type> $form
* @param <type> $form_state
*/
function user_page_content_submit ($form, &$form_state) {
$form_data = $form_state['values'];
/* do the relevant code on form submission..
* like INSERT a record using
* db_query("INSERT INTO ..");
* */
drupal_set_message('Record inserted Sucessfully!');
}
No comments:
Post a Comment