function location_addanother_node_view in Location 7.3
Same name and namespace in other branches
- 7.5 contrib/location_addanother/location_addanother.module \location_addanother_node_view()
Implements hook_node_view().
File
- contrib/
location_addanother/ location_addanother.module, line 12 - "Add location from node view" functionality. Split from main location.module in version 3.
Code
function location_addanother_node_view($node, $view_mode) {
// Load the content type's location settings to see if addanother is enabled.
$settings = variable_get('location_settings_node_' . $node->type, array());
$is_enabled = isset($settings['multiple']['location_addanother']) ? $settings['multiple']['location_addanother'] : 0;
// If addanother is enabled,
// and the number of locations is less then the maximum
// and we're in the full view_mode,
// and the user has access to edit the node,
if ($is_enabled && count($node->locations) < $settings['multiple']['max'] && $view_mode == 'full' && node_access('update', $node)) {
// then display the addanother form.
$addanother_form = drupal_get_form('location_addanother_form', $node);
$node->content['location_addanother'] = array(
'#type' => 'markup',
'#markup' => drupal_render($addanother_form),
);
}
}