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

Re: [kzap] global to cut short variable

Quote Reply
Re: [kzap] global to cut short variable In reply to
Or, if you don't really want the words to get cut off midway;

Code:
sub {
my $field = $_[0];
my $limit = $_[1];
my @sliced = split(" ",$field);

my ($count,$back);
foreach(@sliced) {
if ($count < $limit) {
$back .= $_ . " ";
} else {
$back .= "...";
if ($count == $limit) { last; }
}
$count++;
}

return $back;

}

<%global_name($Description,NumberOfWords)%>

Its a bit more long winded.. but it should do what you want.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Subject Author Views Date
Thread global to cut short variable kzap 2362 Sep 9, 2003, 11:21 AM
Thread Re: [kzap] global to cut short variable
afinlr 2319 Sep 9, 2003, 4:23 PM
Thread Re: [afinlr] global to cut short variable
kzap 2326 Sep 9, 2003, 9:33 PM
Thread Re: [kzap] global to cut short variable
Andy 2319 Sep 10, 2003, 12:39 AM
Thread Re: [Andy] global to cut short variable
kzap 2301 Sep 11, 2003, 11:18 AM
Post Re: [kzap] global to cut short variable
Andy 2307 Sep 11, 2003, 11:22 AM
Post Re: [kzap] global to cut short variable
afinlr 2292 Sep 11, 2003, 3:23 PM