Tags, Tags cloud, behaviors etc...b
I am based my compilation of this useful stuff on This Article.
But, post.php:
nest make posts_tag.php
And the last tag.php
array('className' => 'Post',
'joinTable' => 'posts_tags',
'foreignKey' => 'tag_id',
'associationForeignKey' => 'post_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
}
?>
don't forget to create table in your MySQL database ;-)
Model Post: posts must have fields:
id (bigint)
tags (text) - it's field need to HABTM working properly ;-))
Model Tag: tags
id (bigint)
tag (text, or varchar 255)
Join model posts_tags:
post_id (bigint)
tag_id (bigint)
Ok? Ok!
Now, if you use CakePHP 1.2.0.6311-beta, you'll need to make some things with /lib/model.php
Look at track - ticket.
Ok? Ok! In next post I told you how to make view cloud ;-)
But, post.php:
VALID_NOT_EMPTY,
'email' => VALID_EMAIL,
'body' => VALID_NOT_EMPTY,
);
var $actsAs = array('Tag'=>array('table_label'=>'tags', 'tags_label'=>'tag', 'separator'=>','));
var $hasAndBelongsToMany = array('Tag' =>
array('className' => 'Tag',
'joinTable' => 'posts_tags',
'foreignKey' => 'post_id',
'associationForeignKey'=> 'tag_id',
'conditions' => '',
'order' => '',
'limit' => '',
'unique' => true,
'finderQuery' => '',
'deleteQuery' => '',
)
);
}
?>
nest make posts_tag.php
And the last tag.php
array('className' => 'Post',
'joinTable' => 'posts_tags',
'foreignKey' => 'tag_id',
'associationForeignKey' => 'post_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
}
?>
don't forget to create table in your MySQL database ;-)
Model Post: posts must have fields:
id (bigint)
tags (text) - it's field need to HABTM working properly ;-))
Model Tag: tags
id (bigint)
tag (text, or varchar 255)
Join model posts_tags:
post_id (bigint)
tag_id (bigint)
Ok? Ok!
Now, if you use CakePHP 1.2.0.6311-beta, you'll need to make some things with /lib/model.php
Look at track - ticket.
Ok? Ok! In next post I told you how to make view cloud ;-)
1 Comments:
This comment has been removed by a blog administrator.
Post a Comment
Subscribe to Post Comments [Atom]
<< Home