displaying the Dublin Core of the files associated with an item

Whenever I add a new artist(as an item) to my archive (as a person), I attach files to the item - such as artist's catalogs, images of his works and so on.

Afterward, in the administration panel I am able to add meta data to each file uploaded in relation to the person added as an item. However, all this data that I am entering about the files are not visible on the item's page.

Is there a way I can make visible on the website the meta data for files?

Thank you very much in advance for your help,
Roxana

Roxana,

So far as I understand it, that would be done by adding a little bit of code to the item/show.php file in your theme.

Something along these lines might work:

<?php while(loop_files_for_item()): ?>
   <?php echo show_file_metadata(array('show_element_sets'=> array('Dublin Core') ) ); ?>
<?php endwhile; ?>

The 'Dublin core' buried in the options refers to the element set for the file's metadata. If you are using a different element set, just change the name.

What I wrote above is pieced together from these pages in the theme documentation -- they might provide more and/or better guidance.

http://omeka.org/codex/Theme_API
http://omeka.org/codex/Theme_API/show_file_metadata
http://omeka.org/codex/Theme_API/loop_files_for_item

Good luck,
Patrick

Thank you very much Patrick for your detailed help. I inserted your code and I also tried the suggestion in here: http://omeka.org/codex/Theme_API/show_file_metadata . The problem occurs when I have more than one file, because the meta data for all files just flow after all the files are displayed.

The loop code on the page in Codex has the same problem in my view: after all the files are displayed, it displays a list of the file names.

What I am trying to display is the file meta data followed by the file, then the next file meta data followed by the file and so on. I'm not thinking about all the meta data, but about a selected few, like title, source and description.

As php is rather unknown to me:), I would greatly appreciate any clue that might lead me in the direction described above.

Thank you,
Roxana

I think I'm on to something:). Editing the FileFunctions.php (display_files function) in application/helpers (with the help of a friend) I managed to actually display something underneath each file: the file id or other "internal metadata", but nothing from the Dublin Core.

Now, hoping someone is following my php adventure, the question is what code I can insert inside this function to display underneath each image what this pice of code does (but underneath all files if inserted into show.php):

`<?php
$elementSet = 'Dublin Core';
$elementName = 'Title';
while(loop_files_for_item()) {
$fileTitle = $this->fileMetadata(get_current_file(), $elementSet, $elementName);
echo '<p>' . $fileTitle . '</p>';
}
?>`

Any clue would be highly appreciated:)
Thank you,
Roxana

Well done on the hacking and php adventuring!

But, I'm hoping that we can get to a more elegant solution -- it's usually well-worth the work to find a solution that doesn't involve changing core files of an application [1]

That said, this is an interesting case about displaying file info. Coincidentally, I'm in a similar situation.

A fun game might be to break out an image editor to show exactly what changes you want, based off of a screenshot of what you have. The theming api is really good, but we just might need to dig into some of its more subtle nuances.

Patrick

1 http://www.flickr.com/photos/hagengraf/2802915470/

It looks like you might want to use either display_files_for_item or item_file.

display_files_for_item will try to display info about the file, as well as the correct file itself (that is, the image). It might look something like this:

<?php

display_files_for_item( array('showFilename'=>true,'linkToFile'=>true) );

?>

That should link to the file and display it.

To dig into more of the metadata, item_file will let you at it:

<?php while(loop_files_for_item()): ?>
<p><?php echo item_file('Dublin Core', 'Description'); ?></p>
<?php endwhile; ?>

That should spit out just the description.

Hope that helps!
Patrick

http://omeka.org/codex/Theme_API/display_files_for_item

http://omeka.org/codex/Theme_API/item_file

Patrick, thank you a million times! I'm afraid some kittens will still have to be sacrificed though:).

The problem as I see it is not actually displaying the meta data, cause this has been clearly solved. The main issue is that I need to get inside display_files_for_item somehow, with some Dublin core data and that while(loop_files_for_item) is not really a winner in this endeavor:).

What I'm trying to accomplish looks something like this:
http://poxa.ro/imagini/balsamique.png

And in order to do this, I must somehow be able to display it after after each image, not after all images.

I really can't see a way of doing this without breaking the function, and I can't even break the function properly:).

maybe by displaying it as a table... I'll think about it. Let me know how it goes for you:)

Cheers,
Roxana

I made another image, this time based on the actual page I am working on, as Patrick suggested:

http://poxa.ro/imagini/explicit.png

If anybody has already done this or has another idea in this direction, I would greatly appreciate it.

Thank you,
Roxana

Ah! Now I see what you mean. There should be some clever expression about the value of a picture. . .

The good news is that it looks like we can save some kittens!

Here's a screenshot of what I have going on--hopefully this'll be close enough to what you need to be able to modify from here

http://www.flickr.com/photos/11597705@N00/4502857656/sizes/o/

Here's the code that I put into /items/show.php in the theme:

<div id="itemfiles" class="element">
<h3>Files</h3>
<div class="element-text">
	<?php while(loop_files_for_item()): ?>
		<div class="file-display">
			<!-- Display the file itself-->
			<?php echo display_file(get_current_file()); ?>
			<!-- Display the file's metadata -->
			<div class="file-metadata">
				<h3><?php echo item_file('Dublin Core', 'Title'); ?></h3>
				<p><?php echo item_file('Dublin Core', 'Description'); ?></p>
			</div>
		</div>
		<div style="clear:both"></div>
	<?php endwhile; ?>
</div>
</div>

The while bit loops through the files, and display_file(get_current_file())
shows the images themselves as a link -- hopefully that's the link you have in mind.

Then, for the metadata, item_file can pluck out what we need.

I also had to hack in some styling. Not sure if I did it right -- styling is definitely not my strong point -- but here's what I did:

<style type="text/css">
div.item-file {
	float: left;

}

div.file-metadata {
	position: relative;
	left: 20px;
}

div.file-metadata h3 {
	margin: 5px;
}
</style>

Hope this helps!

Patrick, it works! Thank you for getting me out of the display_files_for_item :)

Your code does exactly what I wanted:

http://poxa.ro/imagini/thank-you-patrick.png

Thank you very much for all your help!

Have a great weekend,
Roxana

Yay! I'm very happy it worked!

And it's really wonderful to see a URL with "thank-you-patrick" in it.

Thanks.
Patrick

Hi!

I'm trying the same thing, but in 2.0 version
Apparently this solution don't work in this version.

I would like to do this without change the core (maybe extending some class from core?)

Someone have a ideia?

Hello!

I can do this in 2.0 version, using code above

<?php
	set_loop_records('files', get_current_record('item')->Files);
	foreach(loop('files') as $file): ?>

		<div class="file-display">
			<!-- Display the file itself-->
			<?php echo file_markup(get_current_record('file')); ?>
			<!-- Display the file's metadata -->
			<div class="file-metadata">
				<?php
		echo all_element_texts(
			$file,
			array('show_element_sets' =>
				array ('Dublin Core')));
			?>
			</div>
		</div>
		<div style="clear:both"></div>

	<?php endforeach; ?>

I didn't resolve only 1 problem: format the data showed. I used all_element_texts function, but only to show all dublin core data without choose what show.

If someone knows how to resolve that =)

Thanks

Fedel,
Thanks for sharing your code so far! We're trying to do the same thing on an Exhibit item show page in v.2.

Your code has helped us get all of the metadata to display for each file, but we only want the Dublin core Title to display.

Did you happen to find a solution that lets you only show certain Dublin Core elements?

Again, thank you for sharing!

Hi,

I forgot to post the solution. See it below

<!-- The following returns all of the files associated with an item. -->
<?php if (metadata('item', 'has files')): ?>
<div id="itemfiles" class="element">
    <h3><?php echo __('Files'); ?></h3>
    <?php
	set_loop_records('files', get_current_record('item')->Files);
	foreach(loop('files') as $file): ?>

		<div class="file-display">
			<!-- Display the file itself-->
			<?php
					echo file_markup(get_current_record('file')); 

			?>
			<!-- Display the file's metadata -->
			<div class="file-metadata">
				<?php
			//getting file data
			$dublin_files = all_element_texts(
			$file,
			array('show_element_sets' =>
				array ('Dublin Core'),
				  'return_type' => 'array'));    

			/*verify if the field exist*/
			if (isset($dublin_files['Dublin Core']['Title']) && isset($dublin_files['Dublin Core']['Description'])) :
			?>
				<h3> <?php echo $dublin_files['Dublin Core']['Title'][0]  ?> </h3>
				<div class ="element-text"> <?php echo $dublin_files['Dublin Core']['Description'][0]  ?> </div>
			<?php endif; ?>
			</div>
		</div>
		<div style="clear:both"></div>

	<?php endforeach; ?>
</div>
<?php endif; ?>

With this i could show only two information (title and description).

I hope I helped you too willette.

=)