When entering in data for an item, many elements are not relevant for certain items. I am wondering how to render the page without those elements/fields. I don't want to use CSS to hide them, since this does not adhere to W3C protocol. Any help is much appreciated.
As noted on the show_item_metadata() theme api page, you'll use the following code:
echo show_item_metadata(array('show_empty_elements' => false));
I'm using the item() to arrange elements in two columns, rather than show_item_metadata(). Here's one example.
<?php echo item('Dublin Core', 'Creator', array('delimiter' => '; ')); ?>
In this case, to display only the items that are not empty, how does one apply
array('show_empty_elements' => false) to the code above? I tried different ways but got errors.
In Omeka sites, post version 1.0, you can control this in the admin Settings panel. By default the checkbox for "Show Empty Elements" is not checked, meaning that empty fields will not be displayed on the public site unless you choose to show them.
Additionally themes in 1.3+ can be configured in the admin panel so that you can determine which Dublin Core fields you display in your theme's items/show page without needing to edit the file.
I am using the Berlin theme, but even if there is no information in the fields, the heading still appears on the page, in this case, the "Creator" heading. I just updated to 1.3, and don't see a way to turn the off also the headings. Any suggestions?
aropro: Have you unchecked the 'Show Empty Elements' option in your settings, as Sheila suggested in her last post?
Since you've said you're manually outputting your headings and
item() to print your metadata, the
show_empty_elements setting will have no effect.
If you don't want to use the
show_item_metadata() helper, then you just need to check for yourself if there is any metadata for a field before you print the heading.
<?php if (($creator = item('Dublin Core', 'Creator', array('delimiter' => '; ')))): ?>
<p><?php echo $creator; ?></p>
<?php endif; ?>
Basically, all this does is first check to see if
item() gave you back any metadata. If there's no data to print, the header doesn't get printed either.
Jeremy, the "Show Empty Elements" is unchecked. John, thanks so much for the code. It works like a charm. I applied the same technique to the other metadata. I'm very close to making this site live! Gracias, all.
I am having the same problem with unused elements showing up, and I have switched the true to false in the show.php file in admin/themes/default/items and I've also made sure the Show Empty Elements option is unchecked, both to no avail. I would like to try your code but am just not sure where and in which file to place it?
Do you want to prevent empty elements from appearing on the public view, or on the admin view? Editing admin/themes/default/items/show.php will only affect the display of items in the admin, not on the public side.
What I want is to prevent them from appearing on the public view, what can I do for this? Thanks! (and that does make sense now, being in the admin folder.)
PS - that doesn't even work for the admin view as I can see all of the [untitled] items in the admin view. :/
I just realized what the problem probably is. The only DC/Metadata that shows up empty is the title, everything else that is blank doesn't show. Does this mean that an item simply MUST have a title? The reason lots of my items don't is because I am creating an entomology collection for a client and have uploaded a CSV file to bring in all of the items. The client wanted the 'common name' to be the title, so that is how I mapped it. Only problem is, lots of the items do not have common names, so they show up as untitled.
The client wants any item that doesn't have a common name to have the Genus species show up as title. Is there any way to do this other than manually switching each one?
Thanks for any help.
If you look in the 'custom.php' file for your theme, you'll see that there is a line like this:
add_filter(array('Display', 'Item', 'Dublin Core', 'Title'), 'show_untitled_items');
This is the code that's causing the
You can simply remove that filter to allow titles to be blank, but I wouldn't recommend it. Omeka generally uses an item's title as the text for the link to the item itself, so if you allow the title to be blank, you can create blank, un-clickable links.
You have a few options for dealing with the titles. You can create a new filter of your own (see the documentation) that display the genus as the title if there is no title.
You could also make sure that you set all the titles the way you want them in your CSV file before importing.