function field_collection_menu in Field collection 7
Implements hook_menu().
File
- ./
field_collection.module, line 220 - Module implementing field collection field type.
Code
function field_collection_menu() {
$items = array();
if (module_exists('field_ui')) {
$items['admin/structure/field-collections'] = array(
'title' => 'Field collections',
'description' => 'Manage fields on field collections.',
'page callback' => 'field_collections_overview',
'access arguments' => array(
'administer field collections',
),
'type' => MENU_NORMAL_ITEM,
'file' => 'field_collection.admin.inc',
);
}
// Add menu paths for viewing/editing/deleting field collection items.
foreach (field_info_fields() as $field) {
if ($field['type'] === 'field_collection') {
$path = field_collection_field_get_path($field);
$count = substr_count($path, '/') + 1;
$items[$path . '/%field_collection_item'] = array(
'page callback' => 'field_collection_item_page_view',
'page arguments' => array(
$count,
),
'access callback' => 'entity_access',
'access arguments' => array(
'view',
'field_collection_item',
$count,
),
'file' => 'field_collection.pages.inc',
);
$items[$path . '/%field_collection_item/view'] = array(
'title' => 'View',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items[$path . '/%field_collection_item/edit'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array(
'field_collection_item_form',
$count,
),
'access callback' => 'entity_access',
'access arguments' => array(
'update',
'field_collection_item',
$count,
),
'title' => 'Edit',
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
'file' => 'field_collection.pages.inc',
);
$items[$path . '/%field_collection_item/delete'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array(
'field_collection_item_delete_confirm',
$count,
),
'access callback' => 'entity_access',
'access arguments' => array(
'delete',
'field_collection_item',
$count,
),
'title' => 'Delete',
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_INLINE,
'file' => 'field_collection.pages.inc',
);
// Add entity type and the entity id as additional arguments.
$items[$path . '/add/%/%'] = array(
'page callback' => 'field_collection_item_add',
'page arguments' => array(
$field['field_name'],
$count + 1,
$count + 2,
),
// The pace callback takes care of checking access itself.
'access callback' => TRUE,
'file' => 'field_collection.pages.inc',
);
// Add menu items for dealing with revisions.
$items[$path . '/%field_collection_item/revisions/%field_collection_item_revision'] = array(
'page callback' => 'field_collection_item_page_view',
'page arguments' => array(
$count + 2,
),
'access callback' => 'entity_access',
'access arguments' => array(
'view',
'field_collection_item',
$count + 2,
),
'file' => 'field_collection.pages.inc',
);
}
}
return $items;
}