Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Shortening a field for display.

Quote Reply
Shortening a field for display.
Hi:



The way I have Links set up now, I have one main detailed page, which is really just a summary page, and this links to 3 or 4 more "specialized" in depth detail pages... So, on the main page, I just want a "taste" of the further information. I was able to chop down my Description field with this global:



Quote:


sub {
no strict;
my ($rec) = @_;
my $short;
my $comma;
my $cs;

my $desc = $rec->{'Description'};
my $id = $rec->{'ID'};
if (length $desc < 175) {
$short = $desc;
}
else {
$short = substr ($desc, 0, 165); $short =~ s/\s\S+?$//;
$cs = chop($short);

until ($comma eq " ") {
$comma = chop($short);
}
$short .= "...&nbsp;&nbsp;(<A HREF=\"http://www.bcdb.com/bcdb/detailed.cgi?film=$id&p=s\">more</A>)";
}
return $short;


I have another field that contains data that looks like this:



Alexander Williams, Randy Haycock (Pocahontas).<BR><B>Supervising Animators</B>: Glen Keane (Pocahontas), John Pomeroy (Smith), Ruben Aquino (Powatan), Duncan Majoribanks (Radcliffe) Dave Pruiksma (Flit), Brian Ferguson (Meeko), Ken Duncan (Thomas), Richard Bazley.<BR><B>Character Animator</B>: David Kuhn, Barry Temple.<BR><B>Effects Animation</B>: Ted Kierscey.<BR><B>Animation Clean-Up</B>: Renee Holt-Bird (Pocahontas)[/quote]

What I would LIKE to do is make a global to cut this field off at the first .<BR><B> for display on the main detail page, and then show all the data on the detailed_crew page. I just am not sure of the perl to do this!



I was hoping someone might help me get this so I can make a global so the above data would come out:



Quote:
Alexander Williams, Randy Haycock (Pocahontas)


Rather than to just limit it to the first 175 characters (which looks sloppy.)



Thanks!



dave
dave

Big Cartoon DataBase
Big Comic Book DataBase

Last edited by:

carfac: May 15, 2002, 10:05 AM
Quote Reply
Re: [carfac] Shortening a field for display. In reply to
Got it!



sub {
no strict;
my ($rec) = @_;
my $short;
my @desc1;
my $desc1;

my $desc = $rec->{'Animator'};
my $id = $rec->{'ID'};
@desc1 = split(/\./, $desc);
$short = $desc1[0];
if ($desc1[1]) {
$short .= "&nbsp;(<A HREF=\"http://www.bcdb.com/bcdb/detailed.cgi?film=$id&p=c\">more</A>)";
}
return $short;
}



Quote:


It works, too.



dave
dave

Big Cartoon DataBase
Big Comic Book DataBase

Last edited by:

carfac: May 20, 2002, 9:05 PM