Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello.
I'm trying to edit my event content type with content templates. I'm trying to get event times, cck fields and location fields to one table. My problem is, nothing shows after that event code. Not even the end code for table is printed. That event code has worked before in template.php, so that is not the problem.
So where could the problem be?
<table class="tiedot">
<?php
$start_date = preg_replace('/^(.*) (.*)$/', '\1', $node->event['start']);
$end_date = preg_replace('/^(.*) (.*)$/', '\1', $node->event['end']);
$start_time = preg_replace('/^(.*) (.*)$/', '\2', $node->event['start']);
$end_time = preg_replace('/^(.*) (.*)$/', '\2', $node->event['end']);
if(($start_time=="00:00:00" && $end_time=="23:59:00") || ($start_time=="00:00:00" && $end_time=="00:00:00")) {
if($start_date==$end_date) {
$output = '<tr><th>Pvm</th><td>'. event_format_date($node->event['start_exploded'], 'custom', "j.n.Y") .'</td></tr>';
} else {
$output = '<tr><th>Alkaa</th><td>'. event_format_date($node->event['start_exploded'], 'custom', "j.n.Y") .'</td></tr>'."\n";
$output .= '<tr><th>Loppuu</th><td>'. event_format_date($node->event['end_exploded'], 'custom', "j.n.Y") .'</td></tr>';
}
}
else {
if($start_date==$end_date) {
$output = '<tr><th>Pvm</th><td>'. event_format_date($node->event['start_exploded'], 'custom', "j.n.Y") .'</td></tr>'."\n";
$output .= '<tr><th>Alkaa</th><td>'. event_format_date($node->event['start_exploded'], 'custom', "H:i") .'</td></tr>'."\n";
$output .= '<tr><th>Loppuu</th><td>'. event_format_date($node->event['end_exploded'], 'custom', "H:i") .'</td></tr>';
} else {
$output = '<tr><th>Alkaa</th><td>'. event_format_date($node->event['start_exploded'], 'custom', "j.n.Y H:i") .'</td></tr>'."\n";
$output .= '<tr><th>Loppuu</th><td>'. event_format_date($node->event['end_exploded'], 'custom', "j.n.Y H:i") .'</td></tr>';
}
}
return $aika;
?>
<?php if (!empty($node->field_jarjestaja[0]['view'])): ?><tr><th>Järjestäjä</th><td><?php print $node->field_jarjestaja[0]['view'] ?></td></tr><?php endif; ?>
<?php if (!empty($node->field_vastuuhenkilo[0]['view'])): ?><tr><th>Vastuuhenkilö</th><td><?php print $node->field_vastuuhenkilo[0]['view'] ?></td></tr><?php endif; ?>
<?php if ($node->locations[0]['name'] || $node->locations[0]['street'] || $node->locations[0]['city']): ?><tr><th>Osoite</th><td><?php if ($node->locations[0]['name']): ?><?php print $node->locations[0]['name'] ?><?php elseif ($node->locations[0]['street']): ?><?php print $node->locations[0]['street'] ?><?php else : ?><?php print $node->locations[0]['postal_code'] ?> <?php print $node->locations[0]['city'] ?></td></tr><?php endif; ?><?php endif; ?>
<?php if ($node->locations[0]['name'] && $node->locations[0]['street']): ?><tr><th></th><td><?php print $node->locations[0]['street'] ?></td></tr><?php endif; ?>
<?php if ($node->locations[0]['additional']): ?><tr><th></th><td><?php print $node->locations[0]['additional'] ?></td></tr><?php endif; ?>
<?php if ($node->locations[0]['street'] && $node->locations[0]['city']): ?><tr><th></th><td><?php print $node->locations[0]['postal_code'] ?> <?php print $node->locations[0]['city'] ?></td></tr><?php endif; ?>
</table>
<?php if (!empty($node->content['image_attach']['#value'])): ?><?php print $node->content['image_attach']['#value'] ?><?php endif; ?>
<?php print $node->content['body']['#value'] ?>
<?php if (!empty($node->content['files']['#value'])): ?><?php print $node->content['files']['#value'] ?><?php endif; ?>
Comments
Comment #1
Azerfin CreditAttribution: Azerfin commentedErm, that row should be "return $output;", but I can't edit my post.