You are here

function simplemeta_meta_load_by_path in Simple Meta 7.2

Same name and namespace in other branches
  1. 8.2 simplemeta.module \simplemeta_meta_load_by_path()
  2. 8 simplemeta.module \simplemeta_meta_load_by_path()
  3. 6.2 simplemeta.module \simplemeta_meta_load_by_path()
  4. 7 simplemeta.module \simplemeta_meta_load_by_path()

Load SimpleMeta entity by path.

Parameters

string|array $path: Single path or list of paths.

string $language: Language code.

Return value

SimplemetaEntity|FALSE SimplemetaEntity metadata object or FALSE on failure.

1 call to simplemeta_meta_load_by_path()
simplemeta_get_page_meta in ./simplemeta.module
Get SimpleMeta entity for a page, by path.

File

./simplemeta.module, line 187
SimpleMeta module.

Code

function simplemeta_meta_load_by_path($path, $language = '') {
  $query = new EntityFieldQuery();
  $condition = is_array($path) ? 'IN' : '=';
  $query
    ->entityCondition('entity_type', 'simplemeta')
    ->propertyCondition('path', $path, $condition)
    ->propertyCondition('language', $language);
  if ($condition == 'IN') {
    $query
      ->propertyOrderBy('fit', 'DESC');
    $query
      ->range(0, 1);
  }
  $result = $query
    ->execute();
  if (!empty($result['simplemeta'])) {
    $row = reset($result['simplemeta']);
    return entity_load_single('simplemeta', $row->sid);
  }
  return FALSE;
}