Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php][mysql] Popularne Tagi -jak?
Forum PHP.pl > Forum > Przedszkole
neverever
Jak zrobić skrypt, a może są gdzieś gotowe, w stylu web 2.0 - Popularne Tagi ?

Mam pole KEYWORDS zawierające słowa kluczowe oddzielone przecinkiem.
Wybrane słowa oczywiście mogą się powtarzać pomiedzy rekordami.

I teraz mój problem polega na tym, że muszę zliczyć liczbę wystąpień dla wszystkich słów kluczowych.


przykład

rekordy:
slowo1, slowo2, slowo 3, slowo4
slowo4, slowo5, slowo6
slowo3, slowo4, slowo5, slowo9
slowo1, slowo5, slowo6
...

wynik:
slowo1 -2x
slowo2 -1x
slowo3 -2x
slowo4 -3x
slowo5 -3x
slowo6 -2x
slowo9 -1x
...

I teraz wypisać koljno wszystkie słowa kluczowe (bez powtórzeń) i w zależności od uzyskanego wyniku przeskalować czcionkę.

Jakl coś takiego zrobić?
cornholio666
Zapytaj google o tag clouds na 100% znajdziesz
neverever
Cytat(cornholio666 @ 7.09.2007, 15:57:00 ) *
Zapytaj google o tag clouds na 100% znajdziesz
no znalazłem na 100% tylko że dla przypadku gdy tagiem jest np. pojedyńcze słowo/klucz
-w sumie to nie musiałem nic szukać żeby to w takim przypadku zrobić, bo wystarczy prosty select count z grupowaniem

ale co zaznaczyłem wcześniej, ja mam w rekordzie więcej słów/kluczy w polu tags,
oddzielonych przecinkiem i w różnej kolejności! - czyli proste grupowanie rekordów nic nie da.

Jak to rozwiązać?
phpion
Obawiam się, że w obecnej postaci takowego edektu nie osiągniesz. Najlepiej zrób to w ten sposób, że stwórz 3 tabele:
- artykul
- tag
- artykul_tag
Pierwsza przechowuje dane artykulow, druga same tagi, trzecia laczy id artykulu z id konkretnego tagu. Baza znormalizowana i ogólnie chyba najszybsze rozwiązanie smile.gif
styljola
Znalazłam skrypt do tagów na www.frozenminds.com
Czy coś podobnego ktoś mógłby udostepnić?
Mam inny szablon strony bez main.tpl i footer.tpl
Moja Strona
Kod
Edit index.php
Edit your index.php file and search for following code line (at the end):

          
//Make output
echo $tpl->fetch('main.tpl', $id);
              
            
              
//Include tagclouds file
require_once 'tagclouds.php';

//Initialize tagclouds class
$tagcloud = new phpld_tagclouds();

//Add array with categories
$tagcloud->add_categories($categs);

//Add array with links
$tagcloud->add_links($links);

//Define minimum occurrences of a word to be displayed
$tagcloud->mincount(0);

//Define maximum number of allowed tags (most important selected, the rest is removed)
//zero or NULL means infinite
$tagcloud->maxWordsCount(25);

//Define minimum length of word to be displayed
$tagcloud->minwordlength(2);

//Define maximum length of a word to be displayed
$tagcloud->maxwordlength(30);

//Define minimum font size of a tag to be displayed (in procent)
$tagcloud->minfontsize(100);

//Define maximum nuber for element class (CSS styling)
$tagcloud->styleclass(5);

//Sort tags (alphabetical, count, random)
$tagcloud->sortmethod('alphabetical');

//Define Change search URL variable (for phpLD 3.0.4+ = "search", all the rest = "q")
$tagcloud->setsearchvariable('search');

//Define a title to be displayed above the tagclouds
$tagcloud->title('<h3>Tag Clouds</h3>');

//Define words to not be displayed (string with words sepparated by comma or space, or an array with one word per key)
$tagcloud->exclude('to,and,if,it,or,about,the,then');

//Assign tagclouds to Smarty template variable "tagclouds"
$tpl->assign('tagclouds', $tagcloud->get_tagclouds());
                  
            
Edit footer.tpl
Note
You can also add this to whatever other template file.


Edit footer.tpl file located in your current template folder (/templates/YourTemplate/ for phpLD 3.0.5+ and /templates/ for all previous versions) and add following code to desired place:

              
{* Display TagClouds *}
{$tagclouds}
              
            
Clean compiled template files
Finally the last step, remove all files located in your /temp/templates/.

Customization
The Tag Clouds output can be fully customized by adding CSS properties.

Customize style
You can easily change properties for fonts, margins, colors or anything else, by adding CSS properties.

The Tag Clouds box is a DIV with class name tagclouds. Style all the rest of the child tags using the parent tagclouds class.

A simple example is:

              
.tagclouds { margin:0 auto; padding:20px; width:70%; border:1px dotted #9EC2F3; }
.tagclouds h3 { font-size:150%; }
.tagclouds .cloud-word { /* add you general rules for ALL tags */ }
              
            
You can also add custom colors and text styling for different tags if you have defined a number for CSS classes:

              
.cloud-style-1 { color:#0000ff; /*blue*/ }
.cloud-style-2 { color:#000; /*black*/ }
.cloud-style-3 { color:#e98800;/*orange*/ }
.cloud-style-4 { color:#0fb400;/*green*/ }
.cloud-style-5 { color:#ff0000;/*red*/ }


Proszę o pomoc smile.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.