<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jotlab &#187; tag_time</title>
	<atom:link href="http://www.jotlab.com/tag/tag_time/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jotlab.com</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Fri, 22 Mar 2013 01:15:26 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Tag Time: CakePHP Tag Plugin</title>
		<link>http://www.jotlab.com/2010/tag-time-cakephp-tag-plugin</link>
		<comments>http://www.jotlab.com/2010/tag-time-cakephp-tag-plugin#comments</comments>
		<pubDate>Tue, 05 Oct 2010 03:41:37 +0000</pubDate>
		<dc:creator>voidet</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[habtm]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tag time]]></category>
		<category><![CDATA[tags]]></category>
		<category><![CDATA[tag_time]]></category>
		<category><![CDATA[voidet]]></category>

		<guid isPermaLink="false">http://www.jotlab.com/?p=4548</guid>
		<description><![CDATA[I needed to integrate a tagging system for a blogging website I was working on with CakePHP. Having read the blog post by teknoid I decided to create a CakePHP plugin along with some jQuery flare for the front end. GitHub: http://github.com/voidet/tag_time The plugin allows... <span><a href="http://www.jotlab.com/2010/tag-time-cakephp-tag-plugin" title="Tag Time: CakePHP Tag Plugin" rel="bookmark">[+]</a></span>]]></description>
				<content:encoded><![CDATA[<p>I needed to integrate a tagging system for a blogging website I was working on with CakePHP. Having read the <a href="http://nuts-and-bolts-of-cakephp.com/2008/07/11/notes-on-cakephp-habtm-part-2-saving-data/">blog post</a> by teknoid I decided to create a CakePHP plugin along with some jQuery flare for the front end.</p>
<p>GitHub: <a href="http://github.com/voidet/tag_time">http://github.com/voidet/tag_time</a></p>
<p>The plugin allows you to attach it to a model with a HABTM relationship established to a tagging based relationship, erm a Posts model to Tags. It will also give you a nice interface for the end user to add tags with, for example:</p>
<p><img class="aligncenter size-medium wp-image-4564" title="Screen shot 2010-10-05 at 4.25.33 PM" src="http://new.jotlab.com/wp-content/uploads/2010/10/Screen-shot-2010-10-05-at-4.25.33-PM-480x162.jpg" alt="" width="480" height="162" align="center" /></p>
<p>Setting up the plugin is quite simple:</p>
<pre class="brush: php; title: ; notranslate">cd app/plugins/
git clone git@github.com:voidet/tag_time.git</pre>
<p>From there you now need to attach the Tag Time behaviour to the model you wish to associate tags with, for example app/models/Post.php</p>
<pre class="brush: php; title: ; notranslate">&lt;?php

class Post extends AppModel {

public $actsAs = array('TagTime.TagTime');
public $name = 'Post';
public $hasAndBelongsToMany = array('Tag');

}

?&gt;</pre>
<p>Of course you will need to create two tables, your join table (posts_tags) and your tags table (tags):</p>
<pre class="brush: sql; title: ; notranslate">CREATE TABLE `posts_tags` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`post_id` int(11) unsigned NOT NULL,
`tag_id` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`)
)

CREATE TABLE `tags` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`tag` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
)</pre>
<p>Next up adding the JS and CSS into your layout, which may change at a later date:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php echo $this-&gt;Html-&gt;css('/tag_time/css/jquery.tagsinput');
echo $this-&gt;Javascript-&gt;link('/tag_time/js/jquery.tagsinput');</pre>
<p>Now in your view for your add/edit pages you will need to create your tags field like:</p>
<pre class="brush: php; title: ; notranslate">echo $this-&gt;Form-&gt;input('Tag.tags', array('div' =&gt; array('class' =&gt; 'tags-input input'), 'label' =&gt; 'Tags'));</pre>
<p>What is going on the with div class you ask? Well this is how I have linked the taggable jQuery plugin to the input field, which will then act like a tags field. So for the last step, you need to add in some js into the view or into your js file:</p>
<pre class="brush: jscript; title: ; notranslate">&lt;script type=&quot;text/javascript&quot;&gt;
$(function(){
$('.tags-input input').tagsInput();
});</pre>
<p>I hope to simplify this a bit more, just decided to make a blog post after an hour of making the plugin. If you have any improvements please let me know. Stay tuned to the github page for future updates.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jotlab.com/2010/tag-time-cakephp-tag-plugin/feed</wfw:commentRss>
		<slash:comments>61</slash:comments>
		</item>
	</channel>
</rss>
