File pages and file search results: how to link to parent item

Hello,

I'm setting up an Omeka site where all items will have a number of files (typically pdf) associated with them. Being able to search for keywords in those files is the main purpose of the archive. The files have relevant meta data, so I really like the file pages (/file/show/{id}) that can be accessed through searching for a keyword.

So, I'm using the item_image_gallery function with the $filesShow option to get thumbnails on the item pages that link to the /file/show pages, which is working as expected.

(The function files_for_item seems to lack this option? The option linkToFile links to the actual file, not the page about the file. Is there a way to get files_for_item to link to the /file/show pages? Or should I just keep using item_image_gallary and forget about files_for_item?)

However, I haven't yet figured out how to create a link the other way: from the /file/show page to the 'parent' item. Since files can also be accessed via the search option (ie, not necessarily directly from the item page), I need to show which item the file is associated with - on the /file/show page but preferably also in the search results. Which template files are responsible for generating these pages (/file/show and search results) and which function can be used to link to the file's parent item?

Any help would be much appreciated!
Thanks in advance,
iris

Hmm... ok, so with a little guess work I've added the line <a href="/items/show/<?php echo metadata('file', 'Item ID'); ?>">Link</a> to /application/views/scripts/files/show.php and that seems to work.
I guess I need to copy that file to the template folder to override the default? I'll report back on my progress...