I am looking for a way to query a set of items in my theme using the "Relation" Dublin Core field. Is it possible to do so with the get_items() function, or do I have to write some custom SQL to do so?
I'm new to Omeka, so if it's possible, I would greatly appreciate a code sample.
There's no exact helper or function for doing this, but this should work:
$elementId = get_db()->getTable('Element')->findByElementNameAndSetName('Dublin Core', 'Relation');
$params = array('advanced' =>
array('element_id' => $elementId,
'type' => 'contains'
'terms' => /* your search term */
)
);
$items = get_items($params);
The example code I posted before is wrong in a bunch of respects, so here's a new, better one:
$elementId = get_db()->getTable('Element')->findByElementNameAndSetName('Dublin Core', 'Relation')->id;
$params = array('advanced_search' =>
array(
array('element_id' => $elementId,
'type' => 'contains'
'terms' => /* your search term */
)
)
);
$items = get_items($params);