Gossamer Forum
Quote Reply
Re: [nir] count word In reply to
Hi,

Yeah, don't see why not.

Try this global:

split_by_words
Code:
sub {

my $word_limit = $_[0];
my $phrase = $_[1];

my @split = split / /, $phrase;

if ($#split <= $word_limit) {
return {
Description => $phrase,
Description_Rest => ''
}
} else {

my (@back,@back_rest);
for (my $i = 0; $i < $word_limit; $i++) {
push @back, $split[$i];
}
for (my $i = $word_limit; $i < $#split; $i++) {
push @back_rest, $split[$i];
}


return {
Description => join(" ", @back) . "...",
Description_Rest => join(" ", @back_rest)
}

}

}

<%split_by_words(20,$Description)%>

..then call with:

<%Description%> for the shorted version, and <%Description_Rest%> for the rest of the description.

The "20" is the number of words you wanna show.

Untested, but should work.

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!

Last edited by:

Andy: Sep 7, 2009, 6:16 AM
Subject Author Views Date
Thread count word nir 7489 Sep 7, 2009, 1:08 AM
Thread Re: [nir] count word
Andy 7346 Sep 7, 2009, 3:45 AM
Thread Re: [Andy] count word
nir 7321 Sep 7, 2009, 4:37 AM
Thread Re: [nir] count word
Andy 7362 Sep 7, 2009, 4:42 AM
Thread Re: [Andy] count word
nir 7325 Sep 7, 2009, 5:43 AM
Thread Re: [nir] count word
Andy 7343 Sep 7, 2009, 5:47 AM
Thread Re: [Andy] count word
nir 7323 Sep 7, 2009, 5:54 AM
Thread Re: [nir] count word
Andy 7338 Sep 7, 2009, 6:05 AM
Thread Re: [Andy] count word
Andy 7382 Sep 7, 2009, 6:17 AM
Thread Re: [Andy] count word
nir 7263 Sep 8, 2009, 12:29 AM
Post Re: [nir] count word
Andy 7237 Sep 8, 2009, 12:30 AM