Gossamer Forum
Quote Reply
count word
I use Andy global Trim_Field for cut the Description after some signs.
Can it count word instead of signs?
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


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

Last edited by:

Andy: Sep 7, 2009, 6:16 AM
Quote Reply
Re: [Andy] count word In reply to
Thanks, can it splits the Description to Description1 and Description2, that the Description2 is the all the Description - Description1
Quote Reply
Re: [nir] count word In reply to
You don't ask for much do you? ;)

Try the modified global above.

Cheers

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] count word In reply to
Thanks,
I get error Unknown Tag: 'Description_Rest'
Quote Reply
Re: [nir] count word In reply to
Does the other tag work?

Cheers

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] count word In reply to
Yes it work, and I check it with Description that is long then the limit
Quote Reply
Re: [nir] count word In reply to
If you add a <%GT::Template::dump%>, which of the "Description" values do you see?

Cheers

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] count word In reply to
Hi,

I think I may have seen the issue.

Try the new global, and then call with:

Code:
<%split_by_words(20,$Description)%>
<%if Description_Rest%>
should have <%Description%> AND <%Description_Rest%> here
<%else%>
should just have <%Description%>, and no value for "<%Description_Rest%>"
<%endif%>

Cheers

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] count word In reply to
Thanks, it workSmilew00t
Quote Reply
Re: [nir] count word In reply to
Great Cool

Cheers

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