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

need some help writing a global for splitting text

Quote Reply
need some help writing a global for splitting text
hi,

i need some help with a global.

for every link i have a column "keywords" where -separeted by commas- is a list of words in.
e.g.: keyword1,keyword2,keyword3,.....

now i need a global that splits the keywordlist so that i can call the keywords one by one.

for example:
<%split_keywords('1')%> should return keyword1
<%split_keywords('2')%> should return keyword2
<%split_keywords('3')%> should return keyword3

can anyone help me with this?

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] need some help writing a global for splitting text In reply to
Code:
sub {
my $kw = shift;
my @ret = split /,/, $kw;

return { keyword => \@ret };
}

<%get_keywords($Keywords)%>

You can loop through it:
Code:
<%loop keyword%>
<%loop_value%>
<%endloop%>

Or call them individually, starting at 0 (like an array):

Code:
<%keyword.0%>

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] need some help writing a global for splitting text In reply to
Cool, yes it works.

Many thanks.

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.