Gossamer Forum
Home : Products : Links 2.0 : Customization :

Format of displaying multiple field.

Quote Reply
Format of displaying multiple field.
I have a multiple filed that I created that has about 20 selections. How can I make it so, when I want that filed to display on the detailed.html page, so it has all the selected fields, and a comma after easch one.

Expample:

Test, Test2, Test3, Test4

and so on.



thanks

intellie Crazy
Quote Reply
Re: [intellie] Format of displaying multiple field. In reply to
I would recommend writing a modification in site_html_templates.pl, for the detailed.html template. Basically, grab the field, and then do a join, with something like;

@multi_select = $IN->param('multi_select');
my $joined = join(",",@multi_select);

I'm not sure on the exact format, as I dont have time to download a copy of Links 2; and there is no copy on my dev PC at the moment, because I only just got it :)

Hope that helps Smile

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Format of displaying multiple field. In reply to
Thanks for you time, but I don't know perl that well.
Quote Reply
Re: [intellie] Format of displaying multiple field. In reply to
Is there anyone who knows how to code this problem so it works?



intellie Crazy
Quote Reply
Re: [intellie] Format of displaying multiple field. In reply to
How about doing something like the following:

assuming you have the following in your links.def file

Colors => [16, 'alpha', 0, 35, 0, '', 'Blue|Green|Brown|Black|Other'],

and

Code:
%db_select_fields = (
isNew => 'Yes,No',
isPopular => 'Yes,No',
isMonthPopular => 'Yes,No',
ReceiveMail => 'Yes,No',
Colors => 'Blue,Green,Brown,Black,Other'
);


Then in your add.html

Code:
<select name="Colors" MULTIPLE Size="5">
<option value="Blue">Blue</option>
<option value="Green">Green</option>
<option value="Brown">Brown</option>
<option value="Black">Black</option>
<option value="Other">Other</option>
</select>


And in modify.html ( I think you need the enhanced template.pm parseer for this )

Code:
<select name="Colors" MULTIPLE Size="5">
<OPTION value="Blue"<%if Colors eq 'Blue'%> SELECTED<%endif%>>Blue</OPTION>
<OPTION value="Green"<%if Colors eq 'Green'%> SELECTED<%endif%>>Green</OPTION>
<OPTION value="Brown"<%if Colors eq 'Brown'%> SELECTED<%endif%>>Brown</OPTION>
<OPTION value="Black"<%if Colors eq 'Black'%> SELECTED<%endif%>>Black</OPTION>
<OPTION value="Other"<%if Colors eq 'Other'%> SELECTED<%endif%>>Other</OPTION>
</select>



Then in db_utils.pl

Code:
sub build_html_record_form {
# --------------------------------------------------------
# Builds a record form based on the config information.
#
my ($output, $field, $multiple, $name);
($_[0] eq "multiple") and ($multiple = 1) and shift;
my (%rec) = @_; $output = "<p><table border=1>"; # Go through a little hoops to only load category list when absolutely neccessary.
if ($in{'db'} eq 'links') {
exists $db_select_fields{$db_cols[$db_category]}
or ($db_select_fields{$db_cols[$db_category]} = join (",", &category_list));
($db_select_fields{$db_cols[$db_colors]} = $db_select_fields{'Mult-Colors'} = join (",", "Blue,Green,Brown,Black,Other"));
}
else {
$db_select_fields{'Related'} or
($db_select_fields{'Related'} = $db_select_fields{'Mult-Related'} = join ",", &category_list);
}




Now for the hard part, which I am going to have to work on ( or maybe one of the gurus could do this part ). In the nph-build.cgi ( search.cgi? ) you will need to split the Colors field. Probably after the split_decode. This routine changes the way the data is stored in the database ( Blue~~Brown~~Other ) and the way it looks after the split_decode ( Blue|Brown|Other ).

But it is late and I am tired and I have to concentrate when I use the split function.

But try this:
in site_html_templates:

Code:
sub site_html_link {

# --------------------------------------------------------
# This routine is used to display what a link should look
# like.

my %rec = @_;

$rec{'Colors'} =~ s,\|,\,&nbsp;,g;

etc, etc



then in your site.html page add:

<%Colors%>

Ouch! I need a new brain to do this. Hey, paul/sponge, help me out here!!!

If you want to do it in the detailed page, just put the $rec{'Colors'} line above in the return &load_template ('detailed.html', { line of the sub site_html_detailed routine in the site_html_templates.pl


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."

Last edited by:

esm: Apr 7, 2003, 8:38 PM
Quote Reply
Re: [esm] Format of displaying multiple field. In reply to
ok, I think that this will cause a problem in the Administration Panel, because the user will select the fields, but in the admin panel the field Colors will show as a drop down menu.

intellie Crazy
Quote Reply
Re: [intellie] Format of displaying multiple field. In reply to
well, it didn't in my admin panel. That is what the MULT tag does - Changes it from a drop down list where you can only select one option to a scrollable list where you can use the control key to select multiple options.


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."