You are here

function rich_snippets_get_schema_from_predicates in Rich Snippets 7

Returns all Schema.org schema in the RDF predicates for a field.

Parameters

array $rdf_mapping: The return value of rdf_mapping_load().

string $field_name: The machine name of the field.

Return value

array An array of Schema.org schema and properties.

2 calls to rich_snippets_get_schema_from_predicates()
rich_snippets_get_rdf_schema_mappings in ./rich_snippets.module
Returns a mapping of schema.org schema to field names.
rich_snippets_has_schemaorg_mapping in ./rich_snippets.apachesolr.inc
Returns TRUE if the field is mapped to a Schema.org schema or property.

File

./rich_snippets.module, line 311
Overrides the standard search results templates and CSS to display results similar to major search engines.

Code

function rich_snippets_get_schema_from_predicates(array $rdf_mapping, $field_name) {
  $schemata = array();
  if (!empty($rdf_mapping[$field_name]['predicates'])) {
    foreach ($rdf_mapping[$field_name]['predicates'] as $predicate) {
      if (0 === strpos($predicate, 'schema:')) {
        $schemata[] = substr($predicate, 7);
      }
    }
  }
  return $schemata;
}