Tag cloud in Drupal with Views & Taxonomy
Taxonomy is a good tool to classify Drupal contents, this is a function inserted in the core and lets you to sign your articles with one or more keywords (i.e. tags). In the following tutorial I will show you how you can create a view block that visualize a list of tags with a simple count in function of the selected language, in other words the tag cloud.
I quote the help in Drupal: "The Taxonomy module allows you to classify the content of your website. To classify content, you define vocabularies that contain related terms (or tags), and then assign the vocabularies to content types. For more information, see the online handbook entry for the Taxonomy module."
The Article content type has already activated the tags field, the others need its inclusion, clicking in Add existing field item inside manage fileds form at the link: http://my_site/admin/structure/types.
|How to add the tags field in a selected content|
Taxonomy: Multilingual Options
In my site I configured the form in http://my_site/admin/structure/taxonomy/tags/edit using this item "Translate. Different terms will be allowed for each language and they can be translated.". Every time I have to publish an article, I take different decisions. If the tags have already been set, no problem: the translation is automatic. If they don't exist, I must verify the correct language (Language neutral, Italian or English?) before the final pubblication. In any case I can check the web page: http://my_site/admin/structure/taxonomy/tags and change the Language type clicking edit link. Finally, If the tag needs localization, I can click in the link TRANSLATE and then I add the correct translation.
|Settings for multilingual options in Taxonomy|
Wikipedia describes it as a visual representation for text data, typically used to depict keyword metadata (tags) on websites, or to visualize free form text. Tags are usually single words, and the importance of each tag is shown with font size or the number of times that it is used in brackets.
In Drupal there is an add-on module called TagCloud, that provides the two types of visualization of your tags. But when I used it, I found some problems in localization and in sorting of tags. I resolved with Views as you can see in the two figures below:
Tag cloud with Views
First you have to create a new view at http://my_site/admin/structure/views using these settings:
In Advanced (on the right side) you have to add in CONTEXTUAL FILTERS part the following item Taxonomy term: Term ID with these settings:
|1 of 2||2 of 2|
Then in RELATIONSHIPS Taxonomy term: Content using Tag
Finally in FILTER CRITERIA (on the left) Content: Language
(13/06/2013) If you don't want to print any similar or useless tags in this view, you can add in FILTER CRITERIA this item: Content: Tag then select is not one and type the list of undesired tags in Select terms from vocabulary Tag.
I put below two useful pictures to show you my settings, and my export view code here: export_tagcloud.txt (you can import in your Drupal site, it is sufficient to click in the import button in the Views menu page and to Paste view code here, but check the incompatibilities!)
|1 of 2||2 of 2|