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

Combine two globals?

(Page 2 of 2)
> >
Quote Reply
Re: [Matthias70] Combine two globals? In reply to
Sorry, serves me right coding before a coffee ;) It should be:

Code:
next if $_ =~ /^(word1|word2|word3)$/;

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!
Quote Reply
Re: [Andy] Combine two globals? In reply to
Hi Andy,
works perfect. Thanks a lot!
What maximum number of excluded words would you recommend?

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Combine two globals? In reply to
Hi,

Nice =)

It shouldn't really matter how many words you exclude (as long as its not hundreds and hundreds :)). The main thing is how easy it will be to maintain if you need to add more words in the future.

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!
Quote Reply
Re: [Andy] Combine two globals? In reply to
Cool and thanks! I just paypaled you ;-)

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Combine two globals? In reply to
Thanks Angelic

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!
Quote Reply
Re: [Andy] Combine two globals? In reply to
Hi Andy,
is there an easy way to weight the words.
For example count words from title 2 times and words from description only 1 time...?
or
if there is the same number of words in title and description just prefer the title words...?

Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Combine two globals? In reply to
What is the global you are currently using? Going back over the thread, there were quite a few changes Whistle

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!
Quote Reply
Re: [Andy] Combine two globals? In reply to
Hi Andy,
at the moment I'm using this global
Code:
sub {
my $tags = GT::Template->tags;
my @words = split(/\s+/,"$tags->{Title} $tags->{Description}");
my @links;
my %seen;
foreach (@words){
s/^\s*//sg;
s/[\.,;:\?!\(\)"]+//sg;
next if length($_)<4;
next if $_ !~ /^[A-Z]/;
next if $_ =~ /^(AB's|Also|Ausgewählte|Ausführlicher|Ausführliche|Anliegen|Aufgabe|Aufgaben|Anhand|Arbeitsblatt|Arbeitsblätter|Arbeitsblättern|Ausdrucken|Angebot|Aufgaben|Anfang|Auswahl|Beliebig|Buch|Bereich|Bereiche|Bereichen|Bild|Bilder|Dazu|Dann|Danach|Dabei|Darf|Dank|Dinge|Dies|Dieses|Dieser|Diese|Dokument|Durchgeführt|Denkbar|Durchführung|Datei|Dateien|Download|Einzelne|Ende|Eine|Einfache|Einfaches|Ergänzung|Erklärung|Entwurf|Entwürfe|Einheit|Einfach|Fach|Fertig|Förderung|Gefunden|Hier|Hilfe|Hierbei|Habe|Jahrgangsstufe|Jugendlicher|Jugendliche|Klasse|Klassen|Kindern|Kinder|Kind|Kann|Können|Kleine|Lizenz|Lernbereich|Mehrere|Maßnahme|Material|Materialien|Planung|Rahmen|Schüler|Schülern|Schülers|Schülerinnen|Schule|Schulen|Schöne|Schöner|Stunde|Stunden|Seite|Seiten|Schwerpunkte|Schriftliche|Schriftlicher|Thema|Unterricht|Unterrichts|Verschiedene|Verfügung|Vielen|Vielleicht|Word-Datei|Word|Wenn|Zuerst)$/;
$seen{$_}++;
}
my $i = 0;
for my $k (sort {$seen{$b} cmp $seen{$a} || lc($a) cmp lc($b) } keys %seen) {
last if $i > 5;
push @links, qq|<a href="$CFG->{db_cgi_url}/search.cgi?query=$k">$k</a>|;
$i++;
}

return join(" - ",@links);

}
Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Combine two globals? In reply to
Hi,

Give this a go:

Code:
sub {
my $tags = GT::Template->tags;

my $ignore = q~^(AB's|Also|Ausgewählte|Ausführlicher|Ausführliche|Anliegen|Aufgabe|Aufgaben|Anhand|Arbeitsblatt|Arbeitsblätter|Arbeitsblättern|Ausdrucken|Angebot|Aufgaben|Anfang|Auswahl|Beliebig|Buch|Bereich|Bereiche|Bereichen|Bild|Bilder|Dazu|Dann|Danach|Dabei|Darf|Dank|Dinge|Dies|Dieses|Dieser|Diese|Dokument|Durchgeführt|Denkbar|Durchführung|Datei|Dateien|Download|Einzelne|Ende|Eine|Einfache|Einfaches|Ergänzung|Erklärung|Entwurf|Entwürfe|Einheit|Einfach|Fach|Fertig|Förderung|Gefunden|Hier|Hilfe|Hierbei|Habe|Jahrgangsstufe|Jugendlicher|Jugendliche|Klasse|Klassen|Kindern|Kinder|Kind|Kann|Können|Kleine|Lizenz|Lernbereich|Mehrere|Maßnahme|Material|Materialien|Planung|Rahmen|Schüler|Schülern|Schülers|Schülerinnen|Schule|Schulen|Schöne|Schöner|Stunde|Stunden|Seite|Seiten|Schwerpunkte|Schriftliche|Schriftlicher|Thema|Unterricht|Unterrichts|Verschiedene|Verfügung|Vielen|Vielleicht|Word-Datei|Word|Wenn|Zuerst)$~;
my @links;
my %seen;
foreach (split(/\s+/,$tags->{Title})){
s/^\s*//sg;
s/[\.,;:\?!\(\)"]+//sg;
next if length($_)<4;
next if $_ !~ /^[A-Z]/;
next if $_ =~ /$ignore/;
$seen{$_}++; $seen{$_}++; # do 2 increases for title matches...
}

foreach (split(/\s+/,$tags->{Description})){
s/^\s*//sg;
s/[\.,;:\?!\(\)"]+//sg;
next if length($_)<4;
next if $_ !~ /^[A-Z]/;
next if $_ =~ /$ignore/;
$seen{$_}++;
}

my $i = 0;
for my $k (sort {$seen{$b} cmp $seen{$a} || lc($a) cmp lc($b) } keys %seen) {
last if $i > 5;
push @links, qq|<a href="$CFG->{db_cgi_url}/search.cgi?query=$k">$k</a>|;
$i++;
}

return join(" - ",@links);

}

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: Aug 27, 2013, 9:55 AM
Quote Reply
Re: [Andy] Combine two globals? In reply to
Ups, I get an bizarre error Wink
Never seen this error before...
Code:
Bizarre copy of HASH in sassign at /www/htdocs/*******/cgi-bin/unterricht/admin/GT/Config.pm line 619.

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Combine two globals? In reply to
Mmm, can you try the modified version above?

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!
Quote Reply
Re: [Andy] Combine two globals? In reply to
Hi Andy,
the error ist gone. Seems to work perfect, but I will do some testing.
Thanks for the rewrite Smile

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Combine two globals? In reply to
Np. Was a simple fix... serves me right for doing it before my morning coffee Whistle
> >