You are here

function rdf_example_rdf_mapping in Examples for Developers 7

Implements hook_rdf_mapping().

This hook should only be used to define the RDF mapping for an entity or bundle that has been defined by this module. On installation, this mapping will be saved to the database. To alter anything in this mapping after module installation (or to alter bundles defined in another module), the RDF CRUD functions should be used, as shown below.

Related topics

File

rdf_example/rdf_example.module, line 25
This is an example outlining how a module can be used to define RDF mappings. We define mappings for a node type defined in this module. We also customize mappings for a node type that is defined in another module, node_example.

Code

function rdf_example_rdf_mapping() {
  return array(
    array(
      'type' => 'node',
      'bundle' => 'recipe',
      'mapping' => array(
        'rdftype' => array(
          'v:Recipe',
        ),
        // We don't use the default bundle mapping for title. Instead, we add
        // the v:name property. We still want to use dc:title as well, though,
        // so we include it in the array.
        'title' => array(
          'predicates' => array(
            'dc:title',
            'v:name',
          ),
        ),
        'recipe_summary' => array(
          'predicates' => array(
            'v:summary',
          ),
        ),
        // The photo URI isn't a string but instead points to a resource, so we
        // indicate that the attribute type is rel. If type isn't specified, it
        // defaults to property, which is used for string values.
        'recipe_photo' => array(
          'predicates' => array(
            'v:photo',
          ),
          'type' => 'rel',
        ),
      ),
    ),
  );
}