SPIP-Contrib

SPIP-Contrib

عربي | Deutsch | English | Español | français | italiano | Nederlands

290 Plugins, 198 contribs On SPIP-Zone, 74 visitors now

Home > Site navigation > Tagcloud > Nuage de mots-clés > A tag cloud written exclusively in spip

A tag cloud written exclusively in spip

the font size of each tag depends on the number of elements associated with that tag

12 February 2009 – by k3utchi

All the versions of this article: [English] [français]

1 vote

All contributions published for previous SPIP versions

Displaying a list of all used tags, the font size of each tag depends on the number of elements associated with that tag

A keyword cloud exclusively written in SPIP. The size of each keyword depends on :

  • the number of articles
  • the number of folders
  • the number of sites that are associated with that keyword

Integrating the cloud into a template

The following code can be used in an include, or added to a template. In the case of an include, you can use the class parameter to specify the class to be applied to the <ul> tag.

For example, if you save the loop in a file called inc-keywordcloud.html, you can write the inclusion like this in your template :

<INCLURE{fond=inc-keywordcloud}{class=your_class}>

Of course in this case you will have to add on the first line of the included file a value for the cache : #CACHE{n}, where n is the lifespan of the list before it is recalculated, measured in seconds. According to the frequency of the changes in the list, choose an appropriate value. #CACHE{3600*24} for example for a daily update of the list.

In the final page, it will result in an unordered list like this :

<div class="tags">
<h3>Tags</h3>
<ul class="your_class">
        <li>...
        ...</li>
</ul>
</div>

The first loop scoremots calculates the score of each keyword and stores it in an array (score). It also gets the upper and lower scores.

The second loop lesmots displays the list of all keywords and sizes them according to their score.

Styling

Here are the lines you have to add to the css, in order to have a cloud-like list, with centered inline keywords.

Setting the font sizes

You can modify a couple of parameters :

Coefficients

To calculate the score of each tag, a folder gives 2 points, an article 1 point and a site 0.25 point.

You can change these coefficients in the following line :

[(#SET{rub,[(#GET{rub}|mult{2})]})][(#SET{art,[(#GET{art}|mult{1})]})][(#SET{sit,[(#GET{sit}|div{4})]})]

Smallest and biggest keywords

The default in the given code is 0.85em for the smallest, and a range of 1.5em to the biggest, i.e 2.35em. Change the values in the following lines to get different sizes and range.

#SET{coef, #GET{place}|div{#GET{ecart}}|mult{1.5}}
[        (#GET{score#ID_MOT}|>{0}|?{<li><a style='font-size:[(#GET{coef}|plus{0.85}...

You can also choose not to display keywords with a score under a chosen minimum value (zero in the given code, which means all tags will be displayed, you can change it in the same above line)

Remarks

The loop excludes all keywords when their group name starts with «_», so that you can easily exclude non semantic groups as long as you use an underscore as the first letter of the group name.

Default order is by group, then alphabetically within each group.

Terms of use



CC-GNU GPL

This software is licensed under the CC-GNU GPL version 2.0 or later.

updated on 3 November 2009

Back to top

Comment on this article

Who are you?
  • [Log in]

To show your avatar with your message, register it first on gravatar.com (free et painless) and don’t forget to indicate your Email addresse here.

Enter your comment here Les choses à faire avant de poser une question (Prolégomènes aux rapports de bugs. )
Add a document

Back to top

Here they're talking

  • (fr) SPIP 3.2, Agenda et FullCalendar

    6 juin – 20 commentaires

    Nous avions publié un article sur la manière d’utiliser FullCalendar avec SPIP 3.0 afin d’afficher des évènements sous forme d’Agenda. La version de FullCalendar a changé avec SPIP 3.2. Le présent article est donc un tutoriel adapté à SPIP 3.2. Pour (...)

  • (fr) Grappes 1.0

    23 novembre 2012 – 36 commentaires

    Présentation et nouveautés Cette version 1.0 du plugin Grappes est un portage pour SPIP 3.x. Le plugin permet de grouper des objets de SPIP dans des grappes. Les objets du core (articles, rubriques, auteurs, etc.) sont pris en charge, ainsi que (...)

  • (fr) Passer un site SPIP sous https://

    23 février 2017 – 41 commentaires

    Comment migrer simplement votre site SPIP de http:// vers https:// Le protocole https:// devient de plus en plus courant : C’est mieux pour la vie privée de tous La plupart des grands sites l’a déjà adopté Certains navigateurs commencent à afficher (...)

  • (fr) PHANTOM (HTML5UP)

    18 juillet – commentaires

    Squelette SPIP pour intégrer le modèle Phantom de HTML5UP. https://html5up.net/phantom Installation A l’activation, le plugin installe aussi les plugins suivants : crayons, favicon, metasplus+, Couleur d’objet, champs extras, SPIP reset centre (...)

  • (fr) Cycle2

    7 août 2014 – 119 commentaires

    La seconde version de la librairie Javascript « jQuery Cycle », qui permet de produire des diaporamas, se nomme « Cycle2 » : http://jquery.malsup.com/cycle2/. Voici cette nouvelle librairie mise en plugin pour SPIP. Si vous utilisez déjà « jQuery (...)