Multiple Inputs: How to call them in the code?

I've created two additional inputs in one Dublin Core metadata field. I know how to do a php call for a datafield in my code (ex. <?php echo item('Dublin Core', 'Type'); ?>, which will display the Type data). However, I've added two more inputs in this Type area. So how can I separately call the original datafield plus the two additional ones? Thx.

John answered a question very similar to this the other day.

http://omeka.org/forums/topic/displaying-mulitple-input

Okay, I looked at that. But what I need to be able to do is to surround each call to the individual inputs with a special div tag. So is it possible to call each input individually like:

<div id="1"><?php echo item('Dublin Core', 'Type1'); ?></div>
<div id="2"><?php echo item('Dublin Core', 'Type2'); ?></div>
<div id="3"><?php echo item('Dublin Core', 'Type3'); ?></div>

Or something like that?

Since I'm not that familiar with php (I can understand a call when I see what it does but I can't understand what to do with the following, so what would be the call here):

"Or, you can pass the 'all' option, which will return a PHP array of the Subjects, which you can deal with however you want."

Hi outtacontext,

The item function is documented in our Codex. There are several examples of its usage on that page. For your specific goals, you could do something like this on your items/show.php template:

<?php
// Return an array of Dublin Core: Type values.
$types = item('Dublin Core', 'Type', array('all' => true));

// Check if the $types array isn't empty.
if (count($types)) {
    // Loop through each type, surrounding it with a div.
    foreach ($types as $key => $type) {
        echo '<div id="'.$key.'">'.$type.'</div>';
    }
}
?>

You could put additional markup in the foreach loop as needed.

Best,
Jeremy

Well, of course, since I am a php newbie, I have a follow up question.

In the foreach code, just how do I create separate markups for each part of the array? What would help me the most is if you showed me the code that has three input entries in the Type array. Thx.

Hi outtacontext,

The code I provided will loop through all the values you've added for the Type field, whether there are three values or three hundred values. Answering your question about creating 'separate markups for each part of the array' really depends on what you want those 'separate markups' to be. The code I provided will generate exactly what you wished for in your previous message. Do you need something different?

I'm sorry to say that we can't provide much support for general PHP questions. The thing you're asking to do does require some understanding of PHP. To get started learning PHP, I suggest visiting the documentation on PHP's website, such as the page explaining the foreach construct and the page explaining arrays. I also have a few book recommendations if you're interested.

Best,
Jeremy

Definitely interested in book recommendations. Thx.

I used your code (but added a style in the div) and got a syntax error. But the error said it was on the line with a comment. However, I think I may know where the issue is. Here's what I added:

<?php
// Return an array of Dublin Core: Type values.
$types = item('Dublin Core', 'Type', array('all' => true));

// Check if the $types array isn't empty.
if (count($types)) {
    // Loop through each type, surrounding it with a div.
    foreach ($types as $key => $type) {
        echo '<div style="float: right; margin-top: 40px; margin-bottom: 2px; margin-left: 14px;" id="'.$key.'">'.$type.'</div>';
    }
}
?>

I think the problem is with the quote marks in the style. Can you give me the correct syntax for that style? I'd appreciate it. Thx.

I just tested the code you pasted, and it works as expected. Can you tell me what the syntax error is, or provide a link to the page where you're trying to add this?

Thanks Jeremy. I found another way to do this by attaching metadata to the image file instead.

But I'd still love to get your recommendations on good PHP books. The challenge for me is that I learn by doing (and I'm learning a lot on this project). Reading a book without having a problem to solve often doesn't hit the mark with me. But I'm game.

I just made a page on the Omeka Codex for Learning PHP. It contains a brief list of websites and books that I think would be helpful.