Hello!
I have entered metadata in repeating fields for some elements, but I'm having trouble reaching that metadata with php. I'm hoping someone can help.
I have been customizing my items/show.php file to call related items, using a custom Item Type Metadata field called SourceIdentifier, which is based on the object's accession number (I probably could have used the Dublin Core field Relation in this way, but my SourceIdentifier element attempts to do that without manually entering all the reciprocal relationships). The way I've been using this works very well when it's a one-to-many relationship, mainly one item is a Physical Object that has many related Still Images. I've been doing it that way so that ALL images are available to the Exhibit Builder. I understand that may no longer be necessary with 2.0, but it's also important for me to be able to make some related images public and others not - so, a separate issue is, can you make some of the attached files for an object public, and others private? In some cases I have around a hundred images related to an object, so I need to be able to have more granular control over each image, with metadata for each image, that I can easily import and export.
Now I'm importing some images that represent more than one object (group photos from an exhibition), so I'm getting into many-to-many relationships. I need to be able to relate these group photos to each of the items that is represented in the photo (which each have other related items). Using my SourceIdentifier field, I should be able to do that without manually entering the relationship in the original item (that's the extra labor that I'm trying to avoid). I first had this as comma separated values in one element entry, but that doesn't seem to work at all, as it seems to require an exact match. It seemed more logical to enter this as repeated fields. However, my attempt to call all of these with php seems to only call the first of the repeats. I've been searching all over trying to find if this is a php issue or an Omeka issue - anything I know about php I've learned from reverse engineering, and I can't find a working example of this to reverse engineer.
So, this item - http://vcomeka.com/vccc/items/show/2773 properly shows the first of the 3 related objects, but not the other 2 (and my layout needs some help, but one thing at a time). Here's the script for the call for related items - the script is pretty clunky in general, so if you have any suggestions for improvement, even outside of this specific question, I'd be very grateful - I'm only copying the first part of the code, for the sake of brevity:
<!-- begin related items - this will display all items related to physical objects, using the source identifier field-->
<div id="item-relateditems" class="element" >
<div class="item-entry">
<?php
$currentid = item('ID');
$source = item('Item Type Metadata', 'Source Identifier');?>
<h6>Related Objects:</h6>
<!-- insert an if statement to see if it's empty-->
<?php if (item('Item Type Metadata', 'Source Identifier') !=''): ?>
<?php
$physicalobjects = get_items(array('type' => 'Physical Object'),5000);
set_items_for_loop($physicalobjects);
while(loop_items()):
?>
<?php if (item('Item Type Metadata', 'Source Identifier') == $source): ?>
<?php if (item_has_thumbnail()): ?>
<div class="item-nimg">
<?php echo link_to_item(item_square_thumbnail()); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
<p style="clear:both">
</p>
<h6>Related Images:</h6>
<!-- insert an if statement to see if it's empty-->
<?php if (item('Item Type Metadata', 'Source Identifier') !=''): ?>
<?php
$stillimages = get_items(array('type' => 'Still Image'),5000);
set_items_for_loop($stillimages);
while(loop_items()):
?>
<?php if (item('Item Type Metadata', 'Source Identifier') == $source): ?>
<?php if (item_has_thumbnail()): ?>
<div class="item-nimg">
<?php echo link_to_item(item_square_thumbnail()); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
<p style="clear:both">
</p>
If you have any ideas of how to solve my problem of calling repeated fields, I'd love to hear them! Thank you so much for your help!
-Arden