I saw a similar thread (now closed) for adding creator but I can’t seem to get this to work. It seems so unintuitive for a search result to only give you the title.
I know I have some sort of syntax wrong. Any help appreciated.
This is what I added to the index.php file here:
<?php $record = get_record_by_id($searchText['record_type'], $searchText['record_id']); $date = metadata($record, array('Dublin Core', 'Date')); ?>
What’s not working, there’s an error, or you’re just not getting the date?
Just a couple things here from what I can see already, and assuming it’s just not changing anything:
First, what you’re editing here is what we’d typically call the “sitewide” search, the one that you get to using the main search box and which can include items, exhibits, pages, etc. Your title says “advanced search” which more often refers to the item-specific advanced search that uses the regular items browse page. If it is the sitewide search results page you’re intending to edit, then no problem.
Second, it’s not usually a good idea to edit the files in application/views/scripts, as you’ll have to remember you edited them when you go to upgrade. Instead we usually suggest that you copy the file into your theme (if the theme does not already have a copy) and edit it there: this would go at search/index.php within your theme, for example.
Finally, the code you’ve shared doesn’t try to print anything out to the page. I don’t know whether you just didn’t include it here, but typically you’d do something like
echo $date; at the end of what you’ve written to display it.
I copied the code and used the file location from another forum post and response that is now closed.
Berlin theme does not have a /search/index.php
I am aware I would have to manually change this in the core after updates and that it is not ideal.
So, where and what code do I use to add date to search results? ANY search result, advanced or otherwise.
On the theme not containing the file you want to edit, I mentioned this in my previous message: the solution is to copy the file out of the Omeka core into your theme. A file at application/views/scripts/search/index.php should be copied to search/index.php within the theme, and then it will be used instead of the core’s version.
Have you tried my suggestion of adding
echo $date; to the code you tried before?