cbe_keywords
Mon interprétation du champ mots-clefs (keywords) associé à chaque article, avec comme idée de départ la généreration d’un nuage de tags (tagcloud).
À quoi peuvent bien servir des mots-clefs, à part bourrer être utilisés dans la meta keywords ?
À bien des choses en somme. Descriptif :
- recherche des mots-clef les plus fréquents
- nuage de tags texte, ou une liste formatée prête à passer en paramètre à un script
- pour un article : obtenir une liste d’articles associés à au moins un mot-clef commun
- pour les Twitter-addicts, les utiliser comme hashtags
Il est possible de restreindre la sélection par sections et/ou catégories.
Aide du plugin
A keywords usage: counts and lists, tagclouds, hashtags
cbe_keywords
Developed with a tagcloud in mind.
Idea inspired by tru_tags and chh_keywords, pieces of code grabbed almost everywhere, borrowed from many plugins developers, you know who you are ... thank you !
Table of contents
Features
- get a simple list of all keywords used (example)
- get a list with number of occurences for each keyword (example)
- build a tag cloud (example)
- build a formatted list ready to pass as a parameter to a script (example)
- get articles that share same keywords with the current one (example)
- turn article keywords into hashtags (example)
Download, installation, support
Download from the plugin page.
Copy/paste in the Admin > Plugins tab to install or uninstall, activate or desactivate.
Visit the forum thread for support.
Tags and attributes
All tags share the common presentational attributes wraptag
, break
, class
, breakclass
. Default values are unset. See Attributes Cross-reference for further information.
- <txp:cbe_all_keywords />
- <txp:cbe_keyword />
- <txp:cbe_keyword_count />
- <txp:cbe_keyword_ratio />
- <txp:cbe_keywords_related />
- <txp:cbe_keywords_hashtags />
<txp:cbe_all_keywords />
Get a list of all keywords.
Can be used in a page or form template, either as a single or container tag.
Attribute | Description and values (default underlined) | Example |
---|---|---|
status |
Search keywords in articles having the specified status
live: selects live articles only sticky: selects sticky articles only all: selects live and sticky articles |
status="all" |
time |
Search keywords in articles posted in the specified timeframe
past: selects past articles only future: selects future articles only any: selects past and future articles note: selecting expired article or not depends on admin preferences |
time="any" |
limit |
Number of keywords to process/display
unset: all keywords integer: only this specified number |
limit="10" |
sortby |
How to sort resulting list
unset: no sorting alpha: sort by alphabetical order weight: sort by frequency |
sortby="weight" |
sortdir |
If sorting the list, direction to use
asc: ascending order desc: descending order |
sortdir="desc" |
section |
Restrict to the (list of) section(s) provided. Can be used in conjunction with the category attribute
unset: all sections string: a section name string: a comma-separated list of section names |
section="my-section" |
category |
Restrict to the (list of) category(ies) provided. Can be used in conjunction with the section attribute
unset: all categories string: a category name string: a comma-separated list of category names |
category="my-cat" |
form |
Form used to process each keyword
unset: no output string: a form name |
form="keyw_form" |
minfontsize |
For a weighted list or a tagcloud: the minimum font size to use (see examples below)
false: no calculation needed integer: number representing the minimum character size |
minfontsize="12" |
maxfontsize |
For a weighted list or a tagcloud: the maximum font size to use (see examples below)
>false: no calculation needed integer: number representing the maximum character size |
maxfontsize="24" |
label |
Label to prepend to the output
unset: no label >string: text for the label |
label="Tags" |
labeltag |
Tag wrapping the label
unset: no tag string: a tag without brackets |
labeltag="h2" |
<txp:cbe_keyword />
Value of the current keyword.
Used as a single tag.
Attribute:
escape
: convert characters to HTML entities - values:
- unset: use UTF8 character set
- html: use ISO-8859-1 character set only
- htmlspecial: convert only special characters (&, ", ', <, >)
<txp:cbe_keyword_count />
How many times the current keyword is being used.
Attributes: no other than the common presentational attributes.
<txp:cbe_keyword_ratio />
How many times the current keyword is being used amongst all the other keywords.
Attributes: no other than the common presentational attributes.
<txp:cbe_keywords_related />
Works as <txp:related_articles />
, but on a keywords basis.
Attribute | Description and values (default underlined) | Example |
---|---|---|
status |
Restrict to articles having the specified status
live: selects live articles only sticky: selects sticky articles only all: selects live and sticky articles |
status="all" |
time |
Restrict to articles posted in the specified timeframe
past: selects past articles only future: selects future articles only any: selects past and future articles newer: selects only articles newer than the one displayed older: selects only articles older than the one displayed note: selecting expired article or not depends on admin preferences |
time="any" |
limit |
Number of articles to retrieve
default: 10 |
limit="5" |
sort |
How to sort resulting list
default: Posted desc Each field in the "textpattern"−table can be used as a sort key |
sort="Title asc" |
section |
Restrict to the (list of) section(s) provided. Can be used in conjunction with the category attribute
unset: all sections string: a section name string: a comma-separated list of section names |
section="my-section" |
category |
Restrict to the (list of) category(ies) provided. Can be used in conjunction with the section attribute
unset: all categories string: a category name string: a comma-separated list of category names |
category="my-cat" |
form |
Form used to process each article
unset: no output string: a form name |
form="keywrel_form" |
label |
Label to prepend to the output
unset: no label string: text for the label |
label="Related" |
labeltag |
Tag wrapping the label
unset: no tag string: a tag without brackets |
labeltag="h2" |
no_widow |
Whether to inhibit line breaks in titles before the last word
default: according to Advanced Preferences boolean: 0 : authorize linebreak, 1 : inhibits linebreak |
no_widow="1" |
<txp:cbe_keywords_hashtags />
keyword1, keyword2, keyword3 become #keyword1 #keyword2 #keyword3
Attributes: the common presentational attributes, plus
limit
: limits the output to the specified number, can be a negative value to return the n last keywords.
Examples
Basic usage
<txp:cbe_all_keywords break=" " />
outputs a single line containing all keywords.
Text tagcloud
<txp:cbe_all_keywords minfontsize="12" maxfontsize="24" sortby="alpha" sortdir="asc" label="Tagcloud" labeltag="h2" wraptag="div" class="tagcloud">
<span style="font-size: <txp:cbe_keyword_ratio />px;"><txp:cbe_keyword /></span>
</txp:cbe_all_keywords>
Try with minfontsize="100" maxfontsize="200"
and style="font-size: <txp:cbe_keyword_ratio />%;"
Flash tagcloud
This is how to construct the parameter to pass to WP-Cumulus, using the internal textpattern search engine, and assuming you have the flash file available:
- Create a form, name it for example param_cumulus and put the following code (in one single line):
<txp:cbe_all_keywords minfontsize="8" maxfontsize="22"><a href='<txp:site_url />?q=<txp:cbe_keyword escape="html" />' style='font-size:<txp:cbe_keyword_ratio />px;'><txp:cbe_keyword /></a></txp:cbe_all_keywords>
- In the script, pass the paramaters this way:
<script type="text/javascript"> ... so.addVariable("tagcloud", "<tags><txp:output_form form="param_cumulus" /></tags>"); ... </script>
Top 10 keywords
<txp:cbe_all_keywords limit="10" sortby="weight" sortdir="desc" wraptag="table" class="allkw">
<tr>
<txp:cbe_keyword wraptag="td" class="kw" />
<txp:cbe_keyword_count wraptag="td" class="count" />
<txp:cbe_keyword_ratio wraptag="td" class="ratio" />
</tr>
</txp:cbe_all_keywords>
Related articles
Titles of the (at most) five latest related articles :
<txp:cbe_keywords_related limit="5" break="br" wraptag="div">
<txp:title />
</txp:cbe_keywords_related>
Links to the (at most) ten related articles older than the current one, and published far in the past :
<txp:cbe_keywords_related time="older" sort="Posted asc" />
Links to the (at most) ten related articles that were immediately published after the current one :
<txp:cbe_keywords_related time="newer" sort="Posted asc" />
Hashtags
<txp:cbe_keywords_hashtags wraptag="p" break="span" class="hashtags" breakclass="tag" />
will generate something like this :
<p class="hashtags">
<span class="tag">#textpattern</span>
<span class="tag">#javascript</span>
<span class="tag">#jquery</span>
</p>
Changelog
- 04 Apr 13 - v0.2 - Added values
time='newer | older'
(than displayed article) for<txp:cbe_keywords_related />
- 11 Jul 11 - v0.1 - Initial release
Sur les mêmes thèmes
cbe_swap_body_excerpt | cbe_if_prod_status | cbe_output_form | Exemples pour cbe_members | cbe_members | Exemples pour cbe_frontauth | cbe_frontauth | cbe_helpful | MonEcharpe | cbe_if_variableCe que vous en pensez
Thank you andre !
Your question has been answered in the textpattern forum
Rechercher
Vous aimez...
... ce que je fais, ce que je suis. Ça vous est utile ou juste agréable. Vous voulez dire merci, alors
Tags
Pour voir l'animation, mettez le plugin Flash à jour !
textpatternpluginutilisateursloginjavascriptvidéosjquerypasswordmot de passemootoolsdiaporamadémopubliere-commerceÀ propos
Je suis développeur web : je crée des sites Internet et en développe les fonctionnalités. Suite →