By Anonymous (not verified) on
Hi,
I've been trying to output a value from multiple merged cck fields in a table cell, and I could use some help.
I have three multiple-value fields ($field_one, $field_two, $field_three) stored using a cck made content type.
The stored values are:
$field_one (a1,a2,a3)
$field_two (b1,b2,b3)
$field_three (c1,c2,c3)
The intended output is (| as cell delimiter, - as value delimiter):
| a1-b1-c1 | a2-b2-c2 | a3-b3-c3 |
My current attempts are modified versions of
<?php foreach ((array)$field_one as $item) { ?>
<td><?php print $item['view'] ?></td>
<?php } ?>
but no matter how I try to modify it it wont work as intended (my php knowledge is severely limited)!
Any help is appreciated, cassius.
Comments
My best attempt so far is
My best attempt so far is this code (but the .tpl.php gets bloated fast and the code isn't very scalable)
Any help is appreciated, cassius.
Bump
Bump
Bump
Bump
I would suggest
I would suggest that you take a few minutes to learn about "foreach" loops and the "implode" function. You can write this with a couple of loops and probably two implodes. It should be very compact and scalable.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
Hi, Anyone writing the loops
Hi, Anyone writing the loops and implode function please?
Thanks in advance!
greetings,
Martijn