I am unable to append the annotation form.I am new to drupal and not able to trace the bug..here is my program
/**
* Implementation of hook_menu().
*/
function annotate_menu() {
$items = array();
$items['admin/settings/annotate'] = array(
//'path' => 'admin/settings/annotate',
'title' => 'Annotation settings',
'description' => 'Change how annotations behave.',
'page callback' => 'drupal_get_form',
'page arguments' => array('annotate_admin_settings'),
'access arguments' => array('administer site configuration')
);
return $items;
}
/**
* Define the settings form.
*/
function annotate_admin_settings() {
$form['annotate_nodetypes'] = array(
'#type' => 'checkboxes',
'#title' => t('Users may annotate these node types'),
'#options' => node_get_types('names'),
'#default_value' => variable_get('annotate_nodetypes', array('story')),
'#description' => t('A text field will be available on these node types to make
user-specific notes.'),
);
$form['array_filter'] = array('#type' => 'hidden');
return system_settings_form($form);
}
/**
* Implementation of hook_nodeapi().
*/
function annotate_nodeapi(&$node, $op, $teaser, $page) {
switch ($op) {
case 'view':
global $user;
// If only the node summary is being displayed, or if the
// user is an anonymous user (not logged in), abort.
if ($teaser || $user->uid == 0) {
break;
}
$types_to_annotate = variable_get('annotate_nodetypes', array('story'));
if (!in_array($node->type, $types_to_annotate)) {
break;
}
// Add our form as a content item.
$node->content['annotation_form'] = array(
'#value' => drupal_get_form('annotate_entry_form', $node),
'#weight' => 10
);
}
}
/**
* Define the form for entering an annotation.
*/
function annotate_entry_form($node) {
$form['annotate'] = array(
'#type' => 'fieldset',
'#title' => t('Annotations')
);
$form['annotate']['nid'] = array(
'#type' => 'value',
'#value' => $node->nid
);
$form['annotate']['note'] = array(
'#type' => 'textarea',
'#title' => t('Notes'),
'#default_value' => $node->annotation,
'#description' => t('Make your personal annotations about this content
here. Only you (and the site administrator) will be able to see them.')
);
$form['annotate']['submit'] = array(
'#type' => 'submit',
'#value' => t('Update')
);
return $form;
}
Comments
please reply!
please reply!