diff --git a/plugins/bean/bean_entity_view.inc b/plugins/bean/bean_entity_view.inc
index a6a5df4..22f8cb3 100644
--- a/plugins/bean/bean_entity_view.inc
+++ b/plugins/bean/bean_entity_view.inc
@@ -28,6 +28,11 @@ class EntityViewBean extends BeanPlugin {
public $entity_id_position = 1;
/**
+ * Entity ID query element.
+ */
+ public $entity_argument = '';
+
+ /**
* Declares default block settings.
*/
public function values() {
@@ -36,6 +41,7 @@ class EntityViewBean extends BeanPlugin {
'entity_view_mode' => '',
'entity_id' => '',
'entity_id_position' => 1,
+ 'entity_argument' => '',
);
$values += parent::values();
@@ -85,8 +91,7 @@ class EntityViewBean extends BeanPlugin {
$form['entity_view_mode'] = array(
'#type' => 'select',
'#title' => t('Entity view mode'),
- '#default_value' => isset($bean->entity_view_mode) ?
- $bean->entity_view_mode : NULL,
+ '#default_value' => isset($bean->entity_view_mode) ? $bean->entity_view_mode : NULL,
'#options' => isset($view_modes[$entity_type_selected]) ? $view_modes[$entity_type_selected] : array(),
'#required' => TRUE,
'#prefix' => '
',
@@ -102,28 +107,34 @@ class EntityViewBean extends BeanPlugin {
$form['entity_id'] = array(
'#type' => 'textfield',
'#title' => t('Entity ID to display'),
- '#default_value' => isset($bean->entity_id) ?
- $bean->entity_id : NULL,
+ '#default_value' => isset($bean->entity_id) ? $bean->entity_id : NULL,
'#description' => t('Leave empty to use the entity currently being viewed.'),
);
$form['entity_id_position'] = array(
'#type' => 'textfield',
'#title' => t('Position of entity ID in the path'),
- '#default_value' => isset($bean->entity_id) ?
- $bean->entity_id_position : 1,
+ '#default_value' => isset($bean->entity_id) ? $bean->entity_id_position : 1,
'#description' => t('The position in the path of the entity ID that is being loaded.'),
'#states' => array(
'visible' => array(
':input[name="entity_id"]' => array('value' => ''),
),
- 'required' => array(
+ ),
+ );
+
+ $form['entity_argument'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Query argument to retrieve the entity ID from'),
+ '#default_value' => isset($bean->entity_argument) ? $bean->entity_argument : NULL,
+ '#description' => t('Leave empty to use the entity currently being viewed.'),
+ '#states' => array(
+ 'visible' => array(
':input[name="entity_id"]' => array('value' => ''),
),
),
);
-
return $form;
}
@@ -132,15 +143,21 @@ class EntityViewBean extends BeanPlugin {
*/
public function view($bean, $content, $view_mode = 'default', $langcode = NULL) {
$content = array();
-
+ $entity = FALSE;
if ($bean->entity_id) {
// ID provided, load this entity.
$entity = entity_load_single($bean->entity_type, $bean->entity_id);
}
- else {
+ elseif ($bean->entity_id_position) {
// Get the current entity of $bean->entity_type in URL position $bean->entity_id_position.
$entity = menu_get_object($bean->entity_type, $bean->entity_id_position);
}
+ elseif ($bean->entity_argument) {
+ if (!empty($_GET[$bean->entity_argument])) {
+ $id = $_GET[$bean->entity_argument];
+ $entity = entity_load_single($bean->entity_type, $id);
+ }
+ }
if ($entity) {
$entity_id = entity_id($bean->entity_type, $entity);