Seite 1 von 2

Modul: Tag Clouds

Verfasst: Mi 6. Jun 2007, 12:53
von djavet
Hallo

Hier ist mein erste Module, ein Tags Clouds, basiert auf die MetaValue von die Seiten.
Es ist ein zwischen samlung von verschidienen Sachen. Testen nur auf 4.6.15 und in ein Sprach.

Temporäre Demo:
http://www.metadelic.com/new_cms/cms/front_content.php

Ich bin nicht ein Profit mit PHP und es bleibt ein Problem mit die Banned Words: es funktionniert einfach nicht.
Ideen?

Tags Clouds mit die MetaValue
- Inspire and adapted from: http://www.ayom.com/faq/tag-cloud-erstellen-a-748.html
- Comma seperated: wort1, wort2, mein wort
- Without space: wort1, wort2, mein wort >> wort1 wort2 meinwort
- Case sensitive
- Banned Words >> Dont work!!! Why?

TODO:
- Banned Words
- Search Pfad Integration


Module als XML:
> http://www.metadelic.com/upload/Tags_Cloud.xml

Output:

Code: Alles auswählen

<?php
$dbConnect = new DB_Contenido;

$query = "SELECT metavalue FROM ".$cfg['sql']['sqlprefix']."_meta_tag order by metavalue";
$dbConnect->query($query);
while ($dbConnect->next_record()) {
   $data[] = $dbConnect->f("metavalue")."\n";
}

$data = str_replace (" ", "", $data);
$data = implode('',$data);

$words = preg_split("/[\s,]+/", $data);
$acv = array_count_values( $words );

$bannedwords = array('janvier');
$i = 0;
foreach($acv as $k=>$v) {
if (!array_search($k,$bannedwords) and eregi("[a-zA-Z]",$k) and $i<=200 and strlen($k)>2) {
if (isset($new_acv[$k] ))
$new_acv[$k] += $v;
else
$new_acv[$k] = $v;
$i++;
}
}

ksort( $new_acv );

echo "<div id=\"tags_cloud\">";

foreach( $new_acv as $k=>$v) {
$size = $v*1;

if ($size > 30) $size = 30;

$kurl = urlencode("$k");
echo "<a href=\"front_content.php?idcat=40&searchterm=$kurl\" class=\"tag{$size}\">$k</a>&nbsp;&nbsp;\n";
}
echo "</div>";
?>

Copy this into your CSS document:

Code: Alles auswählen

	/* Start Tags Cloud CSS */

	#tags_cloud {
	 padding:1px; text-align:left;
	}
	#tags_cloud a {
	 text-decoration:none;padding:0px;
	}

	a.tag1{
	 font-size:12px;
	}
	a.tag2, a.tag3 {
	 font-size:13px;
	 font-weight:200;
	}

	a.tag4 ,a.tag5, a.tag6 {
	 font-size:16px;
	 font-weight:300;
	}

	a.tag7, .tag8, a.tag9 {
	 font-size:20px;
	 font-weight:300;
	}

	a.tag10, a.tag11, a.tag12 {
	 font-size:24px;
	 font-weight:300;
	}

	a.tag13, a.tag14, a.tag15 {
	 font-size:28px;
	 font-weight:400;
	}

	a.tag16, a.tag17, a.tag18 {
	 font-size:30px;
	 font-weight:400;
	}

	a.tag19, a.tag20, a.tag21 {
	 font-size:32px;
	 font-weight:500;
	}

	a.tag22, a.tag23, a.tag24 {
	 font-size:34px;
	 font-weight:500;
	}

	a.tag25, a.tag26, a.tag27 {
	 font-size:36px;
	 font-weight:900;
	}

	a.tag28, a.tag29, a.tag30 {
	 font-size:38px;
	 font-weight:900;
	}
	/* End Tag Cloud CSS */
Danke im Voraus für Ihre Hilfe

Dom

Re: Modul: Tag Clouds

Verfasst: Mi 6. Jun 2007, 14:25
von emergence
djavet hat geschrieben:- Banned Words >> Dont work!!! Why?
versuch mal, anstelle von

Code: Alles auswählen

!array_search($k,$bannedwords)
folgendes

Code: Alles auswählen

!array_key_exists($k,$bannedwords)
nicht getestet...

Verfasst: Mi 6. Jun 2007, 14:51
von djavet
Hallo

Danke, aber es funktionniert nicht...

Dom

Verfasst: Do 7. Jun 2007, 12:26
von djavet
Hallo

Habe ein neue Version gemacht :Tags Clouds II

gleiche wie vorher aber mit:
- With space: wort1, wort2, mein wort >> wort1 wort2 mein wort
- XHTML und Accessibility Integration
- Density

Demo:
> http://www.metadelic.com/new_cms/cms/fr ... 1&client=1

Module in XML:
> http://www.metadelic.com/upload/Tags_Cloud_II.xml

Copy this into your CSS document:

Code: Alles auswählen

/* Start Tag Cloud II CSS */
        /* display the individual items next to each other, not one-per-line */
        .tagscloud LI { 
        	display: inline; 
                color: #999;
        	}

        /* hide the extra context from CSS-enabled browsers, but not for screenreaders */
        .tagscloud SPAN { 
        	position: absolute; left: -999px; width: 990px; 
        	}

        /* size of the tags */
        .tagscloud .tagscloud1 { 
        	font-size: 1em; 
        	}
        .tagscloud .tagscloud2 { 
        	font-size: 1.3em; 
        	font-weight:200;
        	}
        .tagscloud .tagscloud3 { 
        	font-size: 1.6em; 
        	font-weight:300;
        	}
        .tagscloud .tagscloud4 { 
        	font-size: 1.9em; 
        	font-weight:400;
        	}
        .tagscloud .tagscloud5 { 
        	font-size: 2.2em;
        	font-weight:500;
        	}
        .tagscloud .tagscloud6 { 
        	font-size: 2.5em; 
        	font-weight:600;
        	}
/* End Tag Cloud II CSS */
Output:

Code: Alles auswählen

<?php
$dbConnect = new DB_Contenido;

$query = "SELECT metavalue FROM ".$cfg['sql']['sqlprefix']."_meta_tag order by metavalue";
$dbConnect->query($query);
while ($dbConnect->next_record()) {
   $data[] = $dbConnect->f("metavalue")."\n";
}

//$data = str_replace (" ", "", $data);
$data = implode(', ',$data);

//$words = preg_split("/[\s,]+/", $data);
$words = preg_split("/,/", $data);
$acv = array_count_values( $words );

$bannedwords = array('janvier');
$i = 0;
foreach($acv as $k=>$v) {
if (!array_search($k,$bannedwords) and eregi("[a-zA-Z]",$k) and $i<=200 and strlen($k)>2) {
if (isset($new_acv[$k] ))
$new_acv[$k] += $v;
else
$new_acv[$k] = $v;
$i++;
}
}

ksort( $new_acv );

echo "<ol class=\"tagscloud\">\n";

foreach( $new_acv as $k=>$v) {
$size = $v*1;
$countedkeyword = $v*1;

if ($size > 6) $size = 6;

$kurl = urlencode("$k");
echo "<li><span>". $size ." page(s) are tagged with </span><a href=\"front_content.php?idcat=40&searchterm=$kurl\" class=\"tagscloud".$size."\">$k</a> (". $countedkeyword .")</li>\n";
}
echo "</ol>\n";
?>
Das Problem mit die Banned Words ist immer da...
Ideen?

Gruss, Dom

Verfasst: Do 7. Jun 2007, 14:00
von emergence
..aber es funktionniert nicht...
dann

Code: Alles auswählen

!array_search($k,$bannedwords)
in

Code: Alles auswählen

!in_search($k,$bannedwords)
ändern...

beim zweiten modul
wenn ein wort 10 mal vorkommt, heisst das nicht das es auch auf 10 seiten vorkommt -> schreib einfach mal ein wort mehrmals in die eigenschaften des artikels...

Verfasst: Do 7. Jun 2007, 14:08
von djavet
Hallo

Für Banned Words, habe gestet und erhaltet: Fatal error: Call to undefined function: in_search() in...
Es klappt bei dir?


Für das zweites Module, ich habe grat jetzt bemerkt aber finde nicht wieso...
Keine Meinung...
Bin nicht ein PHP Profit... :oops:

Dom

Verfasst: Do 7. Jun 2007, 14:25
von emergence
ähm nicht mein tag
wieso ich da auf in_search komme ist mir sowieso nicht klar...

Code: Alles auswählen

!in_array($k,$bannedwords)

Verfasst: Do 7. Jun 2007, 15:00
von djavet
Hallo

Super! Funktionniert perfekt.

Habe auch das kleine doppel Bug gefunden in Tag Cloud II.
Suche:
$words = preg_split("/,/", $data);
Andern in:
$words = preg_split("/,/", $data);
$words = trim_array($words);
Ich habe die beide XML ändern.

Tag Cloud :
> XML
> Demo

Tag Cloud II:
> XML
> Demo


Gruss, Dom

Verfasst: Do 7. Jun 2007, 15:05
von djavet
Hallo

Ein nice to have, is noch die MetaValu von die Artikel von wo ich bin anzeigen. Wie kann ich es machen?

Habe diese gefunden aber ich weiss nicht wie $list ist generiert:
-> http://contenido.org/forum/viewtopic.ph ... eidartlang

Code: Alles auswählen

<?php 

$article = $list->nextArticle();
$article_id = $article->getField('idart');
$article_idartlang = $article->getField('idartlang');


//
//1 author
//2 date
//3 description
//4 expires
//5 keywords
//6 revisit-after
//7 robots
//

$metakeywords= conGetMetaValue($article_idartlang,5);
echo $metakeywords;
?>

Dom

Verfasst: Do 7. Jun 2007, 15:40
von emergence
vom selben artikel ?
folgender code sollte reichen...

Code: Alles auswählen

<?php

$metakeywords= conGetMetaValue($idartlang,5); 
print_r($metakeywords); 

?>

Verfasst: Fr 8. Jun 2007, 13:12
von djavet
Super!
Funktionniert sehr gut.

Gruss, Dom

Verfasst: Sa 9. Jun 2007, 15:23
von HerrB
Sollte es dann zu einer weiteren Version kommen, bitte den ersten Beitrag aktualisieren... Thx.

Gruß
HerrB

Verfasst: So 11. Nov 2007, 22:11
von Contenider
Wie ändere ich die Abfrage dahingehend ab, dass nur die Daten der Keywords verarbeitet werden?

Ich probiere es schon eine Weile, komme aber nicht weiter...

Nachtrag:

Ich habe es mal so probiert, zwar bekomme ich eine Ausgabe, aber nicht die gewünschte... Natürlich habe ich keine Ahnung :roll:

Code: Alles auswählen

<?php

$dbConnect = new DB_Contenido;

$query = "SELECT keyword FROM ".$cfg['sql']['sqlprefix']."_keywords order by keyword";

$dbConnect->query($query);

while ($dbConnect->next_record()) {
	$data[] = $dbConnect->f("keyword")."\n";
}

$data = implode(', ',$data);

$words = preg_split("/,/", $data);

$words = trim_array($words);

$acv = array_count_values( $words );

$bannedwords = array('janvier', 'javet');

$i = 0;

foreach($acv as $k=>$v) {
	if (!in_array($k,$bannedwords) and eregi("[a-zA-Z]",$k) and $i<=200 and strlen($k)>2) {
	if (isset($new_acv[$k] ))

	$new_acv[$k] += $v;
	else
	$new_acv[$k] = $v;
	$i++;
	}
}

ksort( $new_acv );

	echo "<ol class=\"tagscloud\">\n";

	foreach( $new_acv as $k=>$v) {
	$size = $v*1;
	$countedkeyword = $v*1;

	if ($size > 6) $size = 6;

	$kurl = urlencode("$k");

	echo "<li><span>". $size ." page(s) are tagged with </span><a href=\"index.php?idcat=40&searchterm=$kurl\" class=\"tagscloud".$size."\">$k</a> (". $countedkeyword .")</li>\n";
}
echo "</ol>\n";
?>

Verfasst: Mi 21. Nov 2007, 00:01
von Contenider
Nur um den Post noch einmal nach oben in die Liste der Übersicht zu bringen...

Kann wirklich keiner verraten was ich hier abändern muss, damit ich nur die Daten aus den Keywords der Seite abfrage und auswerte?

Wenn mir jemand veraten kann, wie ich die Dantebankabfrage gestalten muss, bekomme ich es vielleicht auch selbst hin, danke!

Verfasst: Mi 21. Nov 2007, 08:30
von emergence
so einfach ist das bei den keywords nicht...
man kann zwar das keyword leicht extrahieren, aber wie oft das ganze vorkommt muss man sich aus den einträgen in der spalte auto errechnen... (müsstest du auch beim select ergänzen)

da steht sowas wie das hier drinnen...

Code: Alles auswählen

&76=1(CMS_HTML-1)&34=1(CMS_HTML-1)&42=1(CMS_HTML-1)&75=3(CMS_HTML-1)&84=1(CMS_HTML-2)&43=4(CMS_HTML-1)&54=1(CMS_HTML-1)&1=6(CMS_HTML-1)
also die spalte auto mitselektieren und aus den obrigen fragmenten die anzahl ermitteln...
ist leider kein 5 minuten job...