changing field names in item display=>show.php

In:
In themes/../items/show.php removed:

removed:
<!-- Items metadata -->
<div id="item-metadata">
<?php echo all_element_texts('item'); ?>
</div>

and inserted, for example:
<div class="element-text">
<div id="item-tags" class="element">
<h4><b>Author:</b></h4>
<?php echo item('Dublin Core', 'Creator'); ?>
</div></div>

but "Creator" does not become "Author"
etc

does this not work in the latest version of Omeka? If not, how do I retool item fields to display differently

There's no such function item in current versions of Omeka. That function is called metadata now.

Can you step me through this task? So, if I wanted to retool dublin core 'Creator' to display as 'Author' how would I do it?

The best option is probably to actually leave the all_element_texts call there as-is, and instead change common/record-metadata.php in your theme as explained in this older thread.

So edit:
common/record-metadata.php

and all I need to do is:

if ($setName == 'Dublin Core' && $elementName == 'Date') {
$label = 'Date Submitted';

If I wanted to change 'Date' to 'Date Submitted'

That's basically right, if you're keeping with the basic structure from that thread, where $label is what gets printed in the h3.

Added this:
<h3> <?php if ($setName == 'Dublin Core' && $elementName == 'Date') {
$label = 'Date Submitted';?></h3>

to record-metadata.php and placed in:

/themes/berlin/common

and no change has occurred. Must be a simpler way to approach this?

You'll want to keep the stuff changing the label, and the stuff that echos it, separate:

<?php if ($setName == 'Dublin Core' && $elementName == 'Date') {
$label = 'Date Submitted'; }?>

<h3><?php echo $label; ?></h3>

Ok, 'Date Submitted' now repeats almost throughout the public display

my common/record-metadata.php looks like this:

<?php foreach ($elementsForDisplay as $setName => $setElements): ?>
<div class="element-set">
<?php if ($showElementSetHeadings): ?>
<h2><?php echo html_escape(__($setName)); ?></h2>
<?php endif; ?>
<?php foreach ($setElements as $elementName => $elementInfo): ?>
<div id="<?php echo text_to_id(html_escape("$setName $elementName")); ?>" class="element">
<h3><?php echo html_escape(__($elementName)); ?></h3>

<?php if ($setName == 'Dublin Core' && $elementName == 'Date') {
$label = 'Date Submitted'; }?>

<h3><?php echo $label; ?></h3>

<?php foreach ($elementInfo['texts'] as $text): ?>
<div class="element-text"><?php echo $text; ?></div>
<?php endforeach; ?>
</div><!-- end element -->
<?php endforeach; ?>
</div><!-- end element-set -->
<?php endforeach;
=============================================

but my results look like:

Title

The computer consultant's role as a change agent in small business engagements: A qualitative investigation and knowledge-based system proposal
Subject

Artificial Intelligence and Robotics;Industrial Engineering
Creator

Elaine R. Winston
Date

Date Submitted

2000-01-01
Rights

Date Submitted

City University of New York, Graduate Center
Format

Date Submitted

dissertation
Language

Date Submitted

English
Abstract

Date Submitted

Date Accepted

Date Submitted

Dorothy G. Dologite
Access Rights

Date Submitted

Yes
Audience

Date Submitted

Ph.D.
Mediator

Date Submitted

[See Title Page]

You're close but just a little off.

You have this:

<h3><?php echo html_escape(__($elementName)); ?></h3>

<?php if ($setName == 'Dublin Core' && $elementName == 'Date') {
$label = 'Date Submitted'; }?>

<h3><?php echo $label; ?></h3>

That's going to always print the "real" label (the first <h3> line) and then, once it sees Date it's going to additionally print Date Submitted for every element.

What you want to do instead is only print one label for each element, so you need

<?php
if ($setName == 'Dublin Core' && $elementName == 'Date') {
    $label = 'Date Submitted';
} else {
    $label = html_escape(__($elementName));
}
?>

<h3><?php echo $label; ?></h3>

Notice that the first <h3> line is gone.

I think that I need to remove some exiting code and know exactly where to put the above snippet because now I am getting all the fields doubled:

Title
Title
A psychometric study

Subject
Subject
Pre-Elementary

Date Submitted
Date
2001-01-01

etc.

In my previous post, the second example snippet was supposed to completely replace the first (so those lines quoted in the first snippet would all be deleted, with the second snippet in their place).

From what you just posted, it looks like you left an extra line in there, probably this one:

<h3><?php echo html_escape(__($elementName)); ?></h3>

If you're using the code I posted, the only <h3> line in that file should be

<h3><?php echo $label; ?></h3>

Can we start over? Can you email me the file as a .txt file? I am completely lost. Thanks.

OK, how do I do it for other fields? I think i got it to work for date submitted, now how would I would I change creator to author?

The following did not work:
<?php foreach ($elementsForDisplay as $setName => $setElements): ?>
<div class="element-set">
<?php if ($showElementSetHeadings): ?>
<h2><?php echo html_escape(__($setName)); ?></h2>
<?php endif; ?>
<?php foreach ($setElements as $elementName => $elementInfo): ?>
<div id="<?php echo text_to_id(html_escape("$setName $elementName")); ?>" class="element">

<?php
if ($setName == 'Dublin Core' && $elementName == 'Creator') {
$label = 'Author';
} else {
$label = html_escape(__($elementName));
}
?>

<h3><?php echo $label; ?></h3>

<?php
if ($setName == 'Dublin Core' && $elementName == 'Date') {
$label = 'Date Submitted';
} else {
$label = html_escape(__($elementName));
}
?>

<h3><?php echo $label; ?></h3>

<?php foreach ($elementInfo['texts'] as $text): ?>
<div class="element-text"><?php echo $text; ?></div>
<?php endforeach; ?>
</div><!-- end element -->
<?php endforeach; ?>
</div><!-- end element-set -->
<?php endforeach;

Do you want my email?

As a rule, going offline into email only makes the waters muddier for everyone.

The basic thing to remember is that you need to figure out what $label should be once, and only echo it once.

A bunch of elseifs in your current if...else should do what you need. (A switch is another option)

is this what you're suggesting:

<?php
if ($setName == 'Dublin Core' && $elementName == 'Creator') {
$label = 'Author';
} else
{
$label = html_escape(__($elementName));
}

if ($setName == 'Dublin Core' && $elementName == 'Date') {
$label = 'Date Submitted';
} else

{
$label = html_escape(__($elementName));
}

if ($setName == 'Dublin Core' && $elementName == 'Rights') {
$label = 'Institution';
} else

<h3><?php echo $label; ?></h3>
?>

That's not quite the if...elseif...else structure of PHP.

It will look more like

if ($setName == 'Dublin Core' && $elementName == 'Creator') {
$label = 'Author';
} elseif ($setName == 'Dublin Core' && $elementName == 'Date') {
$label = 'Date Submitted';
} elseif ($setName == 'Dublin Core' && $elementName == 'Rights') {
$label = 'Institution';
// more elseif blocks as needed
} else {
 // final else falls back to the default
 $label = html_escape(__($elementName));
}
<h3><?php echo $label; ?></h3>

It'll be a good idea to consult PHP documentation, references, or tutorials about if and switch control flow blocks.

Thank you. That did the trick. More questions: How do I suppress "Dublin Core" from the item display? How do I suppress the term "Files" from the item display?

You can remove 'Dublin Core' from the Appearance->Settings page.

For removing "Files", in the items/show.php page just delete that line from the file.

How do I change "Tags" into something else? I tried the above method, but seems to be controlled by something mechanism.

Also, under the main upload, I would like a title between the main PDF viewer and the supplemental files. I would like the title to be "Supplemental Files" above "webarchive-20151020180314534-00000-6-f0ed50981f2f.warc.gz"

Please see:
http://library.gc.cuny.edu/aleph/item_display_tags.jpg

Assuming you are still looking at the items/show.php page, just look for the header that echos the 'Tags' text.

Similarly for the tweak about adding the "Supplemental Files" text somewhere. Just look in that file, and add it.

I'll again suggest that you look through some tutorials about PHP structures. I think that'll help things move along more efficiently.

So in the show.php borrow the paradigm from record-metadata.php:

<?php
} if ($setName == 'Dublin Core' && $elementName == 'Tags') {
$label = 'keywords';

$label = html_escape(__($elementName));
}

?>

============================================
Supplemental Files does not have a label currently, so how to create?

OK, cannot figure out how to insert different labels into the Files array in show.php.

For example, would like the first file label to say 'PDF File', the second 'Supplemental Fil'e, the third 'Supplemental File 2'

Please see:
http://library.gc.cuny.edu/aleph/files.jpg

How would I insert additional labels above the image of me and then above the the following link:
http://library.gc.cuny.edu/etds/majoringinmeta.net-20150730180915.warc.gz

Do you understand what I am aiming for? Thanks.

You'd have to get rid of a call to files_for_item, if that's what you currently have, and replace it with a loop over the files:

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

<?php endforeach; ?>

Inside that loop you'd echo file_markup($file) to print the file or link itself, and you could add anything else you wanted to like headings. You can check the value of $index if you want to display different headings for each subsequent file.

Still slightly lost.

I overrode with:
`<h3><?php echo __('PDF (Text) File and Supplemental Files:'); ?></h3>
<div id="item-images">
<?php set_loop_records('files', $item->Files); ?>
<?php foreach (loop('files') as $index => $file): ?>
<?php echo file_markup($file) ?>
<?php endforeach; ?>'

Where would I echo each separate label?

Beyond this point starts to get into the realm of general PHP advice rather than Omeka advice, and I try not to go too far down the road toward PHP stuff that's not really Omeka-specific.

If you want labels (or anything) for each file, that needs to be printed within the foreach loop. Since it's a loop, if you want different stuff printed each time through, you're going to need if and else or some other conditional structure to do that. To have the headings vary as you get further along in the loop, what you probably want to be testing in a conditional is $index, as it will start at zero for the first file and increase by 1 for each subsequent file.

Thanks.