Django style comments module for Kohana 2.3
The comments module allows you to quickly attach comments to models without creating extra tables or columns in your database.
Download
comment.zip
Install
Unzip and copy the folder to the Kohana modules directory. Then edit the modules array in your configuration file (application/config/config.php) to include the path to the comments folder.
Your modules array should look similar to this.
$config['modules'] = array
(
// MODPATH.'auth', // Authentication
// MODPATH.'kodoc', // Self-generating documentation
// MODPATH.'gmaps', // Google Maps integration
// MODPATH.'archive', // Archive utility
// MODPATH.'payment', // Online payments
// MODPATH.'unit_test', // Unit testing
MODPATH.'comments', // Comment module
);
Add the comments table to your database
CREATE TABLE IF NOT EXISTS `comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`model_id` int(11) NOT NULL,
`model_name` varchar(128) NOT NULL,
`name` varchar(512) NOT NULL,
`email` varchar(512) NOT NULL,
`website` varchar(512) NOT NULL,
`comment` text NOT NULL,
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
Usage
Include the following methods in your view file.
<?php print comments::load_comments($object);?>
<?php print comments::comment_form($object);?>
Comments
-
Overall I think it's ok.
More control I think is the biggest advantage it gives you compared to Kohana 2. In particular routes are implemented better. Allowing you to create URLs with fewer framework-specific limitations. Reverse routes are a nice feature too, making your code more maintainable.
Having said that there are a couple of things I don't like. The new folder structure is too cluttered for my liking, and in general it feels more verbose to write code in Kohana 3 (In particular the reverse routing).
Unfortunately I have no aspirations to upgrade this module.
What do you think about Kohana 3? Have you thought about upgrading this?