Definition
gmap_cck_field($op, &$node, $field, &$items, $teaser, $page)
gmap_addons/gmap_cck.module, line 208
Description
Define the behavior of a field type.
In most cases, only "validate" operations is relevant ; the rest
have default implementations in content_field() that usually suffice.
Parameters
$op
What kind of action is being performed. Possible values:
- "load": The node is about to be loaded from the database. This hook
should be used to load the field.
- "view": The node is about to be presented to the user. The module
should prepare and return an HTML string containing a default
representation of the field.
It will be called only if 'view' was set to TRUE in hook_field_settings('callbacks')
- "validate": The user has just finished editing the node and is
trying to preview or submit it. This hook can be used to check or
even modify the node. Errors should be set with form_set_error().
- "submit": The user has just finished editing the node and the node has
passed validation. This hook can be used to modify the node.
- "insert": The node is being created (inserted in the database).
- "update": The node is being updated.
- "delete": The node is being deleted.
&$node
The node the action is being performed on. This argument is passed by
reference for performance only; do not modify it.
$field
The field the action is being performed on.
&$items
The contents of the field in this node. Changes to this variable will
be saved back to the node object.
Return value
This varies depending on the operation.
- The "load" operation should return an object containing extra values
to be merged into the node object.
- The "view" operation should return a string containing an HTML
representation of the field data.
- The "insert", "update", "delete", "validate", and "submit" operations
have no return value.
Related topics
Name | Description |
| Hooks | Allow modules to interact with the Drupal core. |
Code
<?php
function gmap_cck_field($op, &$node, $field, &$items, $teaser, $page) {
switch ($op) {
case 'view':
$context = $teaser ? 'teaser' : 'full';
$formatter = isset($field['display_settings'][$context]['format'])
? $field['display_settings'][$context]['format'] : 'default';
foreach ($items as $delta => $item) {
$items[$delta]['view'] = content_format($field, $item, $formatter, $node);
}
return theme('field', $node, $field, $items, $teaser, $page);
}
}
?>