Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
78 lines (52 sloc) 2.68 KB
= Tags extension
Created by: Keith Bingman - keithbingman.com
Revived by: Benny Degezelle - gorilla-webdesign.be
New features by: Jim Gay - saturnflyer.com
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 http://wiki.radiantcms.org/Using_the_Shards_Extension).
== 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
<r:search:empty>
<h2>I couldn't find anything tagged with "<r:search:query/>".</h2>
</r:search:empty>
<r:search:results>
<h2>Found the following pages that are tagged with "<em><r:search:query/></em>".</h2>
<ul>
<r:search:results:each>
<li><r:link/> - <r:author/> - <r:date/></li>
</r:search:results:each>
</ul>
</r:search:results>
== 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 24ways.org; http://24ways.org/2006/marking-up-a-tag-cloud
== 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 />
</r:tagged>
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.