I am having trouble getting the field to display. I copied the body from contemplate into a custom node.tpl.php file but it is only displaying the h3 tag. below is the code.

<div class="field field-type-office-hours field-field-hours">
  <h3 class="field-label">Hours of Operation</h3>
  <div class="field-items">
    <?php foreach ((array)$node->field_hours as $item) { ?>
      <div class="field-item"><?php print $item['view'] ?></div>
    <?php } ?>
  </div>
</div>

Comments

Ozeuss’s picture

This is because there is no $item['view'], but an $item['day'], $item['starthours'], and $item['endhours'].

TaPes’s picture

can you be a little bit more specific?

i tried this:

<?php foreach ((array)$field_FIELDNAME as $item) { ?>
      	    <?php print $item['day'] ?> 
            <?php echo t(' ') ?>
            <?php print $item['starthours'] ?>
            <?php echo t(' - ') ?>
            <?php print $item['endhours'] ?>
    	<?php } ?>

i get this output:

6 9:00 - 20:00

but i need:

Monday 9:00 - 20:00
Tuesday 9:00 - 20:00
Wednesday 9:00 - 20:00
Thursday 9:00 - 20:00
Friday 9:00 - 20:00
Saturday 9:00 - 20:00
Ozeuss’s picture

The days are stored as integers, you'll need something like

$daykey= check_plain($item['day']);
 $days=array(0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'),3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday'));
   $day= $days[$daykey];

for the day itself to show.
For some reason, you template displays only saturday. I'm not familiar with contemplate or the method you're pulling the $node->field_name, so i can't help you there.

TaPes’s picture

yeah i have found out that only the last day that you select appears on the site. but i have the same problem when i don't use a template:

Saturday 9:00 - 20:00

instead

Monday 9:00 - 20:00
Tuesday 9:00 - 20:00
Wednesday 9:00 - 20:00
Thursday 9:00 - 20:00
Friday 9:00 - 20:00
Saturday 9:00 - 20:00

Never mind, i use cck time, now

johnv’s picture

Status: Active » Closed (won't fix)

Please re-open if this issue still arises in D6/D7.