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

Re: Global Tag to Shorten Description

Quote Reply
Re: Global Tag to Shorten Description In reply to
OK, I THINK I know the problem.... but I definitely found an answer!

I think the global must just return one variable per page built, and thus I only got one short list of characters per page. So, I figured I needed to tweak the link where it is built... in SiteHTML.pm

So, I adjusted Alex's code to make it work in a script, and came up with:
In Reply To:
# Set Up a Short Character List

my $short;
my $desc = ${$rec}{'Characters'};
if (length $desc < 100) {
$short = $desc;
}
else {
$short = substr ($desc, 0, 100);
$short =~ s/\s\S+?$//;
$short .= "...";
}
$rec->{short} = $short;
And this worked right out of the box!

One question to the perl guru's, if I could... would you explain EXACTLY what

$short =~ s/\s\S+?$//;

Means? And, since I assume this is the part that cuts at a white space, and since I am using this in my characters list, can I mod it to cut just before the last comma before 100 characters?

(A character list might look like: "Captain Kirk, Mr. Spock, Dr. McCoy, Scotty, Lieutenant Sulu, Lieutenant Uhura, Transporter Chief Kyle, Pod Ship, Malignant alien." The above code chops this to: "Captain Kirk, Mr. Spock, Dr. McCoy, Scotty, Lieutenant Sulu, Lieutenant Uhura, Transporter Chief...." Which is OK... but I would want to cut it between "Uhura" and the following comma...)

One final note!~ The above code is to shorten Characters (which is my own field). If you use this for Description, make the approipriate edits!

dave



Subject Author Views Date
Thread Global Tag to Shorten Description carfac 5822 Jan 20, 2001, 10:04 AM
Thread Re: Global Tag to Shorten Description
Alex 5685 Jan 20, 2001, 10:14 AM
Thread Re: Global Tag to Shorten Description
carfac 5687 Jan 20, 2001, 10:58 AM
Thread Re: Global Tag to Shorten Description
carfac 5668 Jan 21, 2001, 10:10 AM
Thread Re: Global Tag to Shorten Description
pugdog 5686 Jan 21, 2001, 2:40 PM
Thread Re: Global Tag to Shorten Description
carfac 5684 Jan 21, 2001, 3:40 PM
Post Re: Global Tag to Shorten Description
pugdog 5632 Jan 21, 2001, 4:30 PM
Post Re: Global Tag to Shorten Description
Alex 5600 Jan 30, 2001, 4:13 PM
Thread Re: Global Tag to Shorten Description
BryanL 5523 Mar 19, 2001, 5:30 AM
Thread Re: [BryanL] Global Tag to Shorten Description
bannerzone 5162 Aug 28, 2003, 4:22 PM
Thread Re: [bannerzone] Global Tag to Shorten Description
pugdog 5118 Aug 29, 2003, 8:27 AM
Post Re: [pugdog] Global Tag to Shorten Description
bannerzone 5129 Aug 29, 2003, 3:14 PM
Post Re: Global Tag to Shorten Description
carfac 5679 Jan 20, 2001, 10:41 AM