Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Displaying Multiple Field Values

Quote Reply
Displaying Multiple Field Values
Hi-

I am using check boxes for a field that can have multiple values, and I would like to format these multiple values such that they are displayed as a list with commas. For example if the field is called Color and the selected values are:

Red
Green
Blue

and the user selected these in checkboxes, I would like to be able to display them on a template as: Red, Green, Blue

Right now they list with a space between them, but I'm hoping there's a way to get a comma in there, except on the last one...

Does anyone know how to do this?

-jw



Quote Reply
Re: Displaying Multiple Field Values In reply to
Hi,

You would need code to do this. If you add into globals:

colors_formatted =>
Code:
sub {
my $tags = shift;
my $output = join ", ", split (/\n/, $tags->{Colors});
return $output;
}
where 'Colors' is the name of the field you have. Then just put <%colors_formatted%> where you want it displayed.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Displaying Multiple Field Values In reply to
Fantastic! I tried it and it worked perfectly. Many thanks.

-jw

Quote Reply
Re: [Alex] Displaying Multiple Field Values In reply to
Hi Alex,

I'm trying to do this through page.cgi but can't get it work.

Using your code (and I've tried numerous others)
page.cgi?p=search_custom&d=1&f=hello&f=helloagain
just returns
hello

I understand this may not be enough information, but can you think of a reason why it wouldn't work.?

peace.
kyle