Bloge-Tags
Description
Bloge-Tags adds easy tagging to PmWiki by letting the built-in (:keywords:)
directive and [[!Category links]]
also define page tags, which may be listed with a page variable {$TagList}
or with a pagelist for a tag cloud.
Bloge-Tags is a part of Cookbook.Bloge, but may also be used as a standalone recipe.
To install this recipe:
- download bloge-tags.phpΔ to your cookbook directory
- add the following line to your configuration file:
include_once("$FarmD/cookbook/bloge-tags.php");
Usage
By default Bloge-Tags assumes that page keywords, categories and tags all mean the same thing, but is configurable to believe otherwise. Hence you may use (:keywords word1, word2, ...:)
and [[!Category links]]
as usual to also define page tags, which may be then listed using a new page variable {$TagList}
.
{$TagList}
- A comma-separated list of all tags for this page, as category links.
{$TagCount}
- The number of tags for this page; returns '' for none.
(:pagelist fmt=tags:)
- A tag cloud of all the tags from pages matching the pagelist parameters.
A few of the parameters are handled separately, ascount
andorder
(valid values arename, -name, freq, -freq
) control how the tags, not pages, are listed.
An additional optiontagfilter
accepts a comma-separated list of filter rules for including or excluding tags (prefix with-
to exclude, wildcards?*
are ok).
Configuration
The following variables may be set in your config file to control the way Bloge-Tags works.
$BlogeTag['group']
- default:
$CategoryGroup
The group to use for tags. If set to something other than
(which in turn by default is$CategoryGroup
'Category'
) category links won't get listed as tags. $BlogeTag['linkfmt']
- default:
'[[!$TagName]]'
How to make a link from a tag name. In order to get your tag list without links, use$BlogeTag['linkfmt'] = '$LinkText';
. Markup and HTML are both supported. $BlogeTag['listfmt']
- default:
'%font-size=$sizepct%[[!$tag]]%% '
How to make a tag cloud link from a tag name. The following strings will be replaced by corresponding values:'$tag', '$count', '$group', '$size'
. For an alternative unordered list, you could use$BlogeTag['listfmt'] = '* %item font-size=$sizepct% [[!$tag]]'."\n";
. $BlogeTag['min-size']
- default:
80
$BlogeTag['max-size']
- default:
160
The minimum and maximum values of$size
in$BlogeTag['listfmt']
, corresponding to$count
values of 1 and the maximum for the current list. $BlogeTag['prefix']
- default:
'$[Tags]: '
The string to add at the beginning of the tag list when at least one tag is present, in markup. $BlogeTag['separator']
- default:
', '
The string separating tags from each other, in HTML. $BlogeTag['tagfilter']
- default:
''
An array in the style of MatchPageNames$patterns
for including or excluding tags in the tag cloud, appended to by thetagfilter=
option.
Notes
For speed, the list of tags is generated from the page targets array, which is set when the page is edited. Hence if you've defined keywords for your pages before including the recipe, those keywords won't get listed as tags until you've at least once saved the page (no need to make any changes, just save the page).
The templating/formatting of tag lists for single pages and for pagelists is a mess at the moment. Fixing this will probably happen once PITS.01102 gets resolved.
The recipe may be included in a per-group or per-page customization file to limit its functionality to that group or page.
It might be a good idea to use EditAttributes to add a separate edit field for the page keywords to your editing form.
The easiest way to get category links to not show on the page is to use %comment%[[!Category]]%%
. For a more thorough solution try adding $LinkCategoryFmt = ' ';
to a config file. That'll hide all your category links but still let them get listed using {$TagList}
. Note that the format string can't be empty or it'll get ignored.
Release notes
- 2022-03-28Δ — made it compatible with php >= 5.5, according to PmWiki.CustomMarkup Siegfried Seibert
- 2009-10-13Δ — tag cloud
tagfilter
&count
options,order
oddity possibly fixed (thanks to SH and SteP) - 2009-08-28Δ — changed some defaults, bugfix for empty tag cloud
- 2009-08-13Δ — bugfix: fmtlist had a space as first character, which messed up sites with
$EnableWSPre
not set to zero (reported by SH) - 2009-08-12Δ — pagelist fmt=tags for tag clouds
- 2009-08-11Δ — prefix + no
(:tag-list:)
directive; using page variables instead - 2009-08-10Δ — first public release
See also
- Cookbook.Bloge — A bundle of blogging
- Cookbook.ListCategories — use categories as tags
- Cookbook.TagPages — Allow categorizing/tagging of pages with an easy interface.
- Cookbook.Tags — How to have tags (like Flickr)
- PITS.01102 — Break FPLTemplate function into several functions to create development hooks
- Cookbook.FPLTemplate — Alternative FPLTemplate() function with hooks for developers for more flexible pagelist output
- rel="tag" — The microformat specification
Contributors
Comments
See discussion at Bloge-Tags-Talk
User notes +2: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.