function farm_ui_views_area_argument_position in farmOS 7
Encapsulates logic for figuring out where the area ID argument is in a View.
Views of assets should always have an area ID as their first contextual filter.
Views of logs are a bit more complicated. Most logs apply to assets, so they have an asset ID contextual filter first, and an area ID contextual filter second. However, some logs do not apply to assets, so the first contextual filter is the area ID.
This function will use information provided by hook_farm_ui_entities() to determine the position of the area ID argument. In general, it will return 1 (the first argument position). If the entity type is 'log', and the log type does not apply to assets, then it will return 2 (second argument).
Parameters
$type: The entity type.
$bundle: The entity bundle.
Return value
int Returns the position of the area ID argument as an integer.
2 calls to farm_ui_views_area_argument_position()
- farm_ui_area_links in modules/
farm/ farm_ui/ farm_ui.farm_area.inc - Generate area links for farm_asset or log entity types.
- farm_ui_farm_ui_entity_views in modules/
farm/ farm_ui/ farm_ui.farm_ui.inc - Implements hook_farm_ui_entity_views().
File
- modules/
farm/ farm_ui/ farm_ui.module, line 357 - Farm UI module code.
Code
function farm_ui_views_area_argument_position($type, $bundle) {
// Load entity UI information.
$ui_info = farm_ui_entities($type, $bundle);
// Default the area ID argument position to 1.
$arg = 1;
// If this is a log entity that applies to assets, the argument position
// should be 2.
if ($type == 'log' && (empty($ui_info['farm_asset']) || $ui_info['farm_asset'] != 'none')) {
$arg = 2;
}
// Return the argument position.
return $arg;
}