You are here

function aet_entity_is_page in Advanced Entity Tokens 7

Checks if the current page is the full page view of the passed-in entity.

Parameters

int $entity_id: An entity id.

string $id_key: The entity id key (e.g. nid for nodes, fid for files).

1 call to aet_entity_is_page()
_aet_entity_tokens in ./aet.tokens.inc
INTERNAL implementation of hook_tokens specified for entities.

File

./aet.module, line 88
The AET main module file.

Code

function aet_entity_is_page($entity_id, $id_key) {

  // Returns the object of the entity being viewed.
  $page_entity = menu_get_object();

  // Checks if no entity is being viewed or if it doesn't contain the a property
  // with $id_key as it's key.
  if (empty($page_entity) || !isset($page_entity->{$id_key})) {

    // If the above check is true than the passed in entity is not being viewed
    // directly.
    return FALSE;
  }

  // Returns true if the id of the passed in entity is equal to the id of the
  // entity being viewed.
  return $page_entity->{$id_key} === $entity_id;
}