I am trying to build a function to loop through all the items with a certain metadata. This is what I have built up so far:
$items = get_items(array('Creator' => 'Eric'),3);
<?php if (has_items_for_loop()): ?>
<?php while (loop_items()): ?>
<h3><?php echo link_to_item(); ?></h3>
<?php if($desc = item('Dublin Core', 'Subject', array('snippet'=>150))): ?>
<div class="item-description"><?php echo $desc; ?></div>
<?php endif; ?>
<?php endwhile; ?>
<?php else: ?>
<p>No recent items available.</p>
<?php endif; ?>
However, as mentioned in http://omeka.org/codex/Theme_API/get_items
the available argument for $params only include:
collection - Collection ID
featured - true or false
range - A range of item IDs
recent - true or false
tags - A string of comma-separated tags
type - Type ID
user - User ID
sort_field (see Sorting Results)
sort_dir (see Sorting Results)
Is it possible to achieve this goal ($items = get_items(array('Creator' => 'Eric'),3);) by another way? Thank you.
This is using Omeka 1.x?
get_items, you can also use a parameter
'advanced_search', which basically just filters using the "Narrow by Specific Fields" options from the Advanced Search.
You can look at the search page for some more details, but basically, that
'advanced_search' key expects the value to be an array of "rows," each specifying the search terms, the matching type, and the element to match against. Something like the following:
array('advanced_search' => array(
'element_id' => 39,
'type' => 'is exactly',
'terms' => 'Eric'
This makes the assumption that Dublin Core Creator is element 39, which is what it's installed as. You can get element ID's programmatically using the Element table instead.
Is there a way to find the desired element ID without looking at the element table? For the project I'm working on, I don't currently have direct access to the DB to check that. I need the Dublin Core Relation element - and I'm still using 1.5.3.
You can get all that information from within Omeka, since it obviously has access to the database.
$element = get_db()->getTable('Element')->findByElementSetNameAndElementName('Dublin Core', 'Relation');
$id = $element->id;
The above is the "safe" way of getting that ID. As installed, Relation should be ID number 46 (you can find those default IDs in application/core/schema/elements.sql, but it's possible to have different IDs in your particular installation).
I figured there had to be a way! Thanks - that was just what I needed.