Find file
Fetching contributors…
Cannot retrieve contributors at this time
78 lines (52 sloc) 2.68 KB
= Tags extension
Created by: Keith Bingman -
Revived by: Benny Degezelle -
New features by: Jim Gay -
Version: 0.2
Contact: benny AT gorilla-webdesign DOT be
This extension enhances the page model with tagging capabilities, tagging as in "2.0" and tagclouds.
== Requirements
This extension depends on the shards extension and the has_many_polymorphs plugin
Shards should be installed and loaded first; you can change the load order of extensions in config/environment.rb (see
== Installation
1. Copy the extension to your vendor/extensions directory as you would any other extension.
2. From your instance root, run 'rake db:migrate:extensions' to create meta_tags & taggings tables.
3. Then run 'rake radiant:extensions:tags:install'
Which will copy tags.css to your stylesheets folder. You might want to edit this file.
4. Add the tags.css to your layout;
<link rel="stylesheet" type="text/css" href="/stylesheets/tags.css" />
5. Make a page to sit in /search/by-tag, and give it the "Tag Search" pagetype.
If you want to change this location, it's in Radiant::Config['tags.results_page_url'].
Copy the results page example below, and modify to your likings;
== Results page
<h2>I couldn't find anything tagged with "<r:search:query/>".</h2>
<h2>Found the following pages that are tagged with "<em><r:search:query/></em>".</h2>
<li><r:link/> - <r:author/> - <r:date/></li>
== Tag cloud
Use <r:tag_cloud /> anywhere you like.
I made a stab at building the 'perfect' tag cloud markup, as inspired by a post on;
== Tag list
Use <r:tag_list /> to get a list of tags for the current page.
Also works through children:each.
== All tags
Use <r:all_tags /> to get a list of all tags. You may iterate through them with
<r:all_tags:each> and access their associated pages with <r:all_tags:each:pages:each>
== Collections
You can grab a collection of pages with a certain tag like so;
<r:tagged with="sometag" [scope="/some/page"] [with_any="true"]>
<r:link />
Which would iterate over all the resulting pages, like you do with children:each.
When you define scope, only this page and any of it's (grand)children will be used.
You can also set limit, offset etc like with children:each.
Using r:tagged in it's default setting searches for pages that have all of the given tags.
Using r:tagged with the attribute 'with_any' set to 'true' will find pages that have any of
the given tags.