After build front end component, may be your visitor want to leave comment about your posting. May be they have different opinion. Don't worry. It will make your site more attractive.
This tutorial will show step by step how to add comment function in your component. Let's do it!
- Create "comment.php" within joomla/administrator/components/com_hello/tables. Enter following code:
<? defined( '_JEXEC' ) or die( 'Restricted access' ); class TableComment extends JTable { var $id = null; var $hello_id = null; var $user_id = null; var $full_name = null; var $comment_date = null; var $comment_text = null; function __construct (&$db) { parent::__construct( '#__hello_comment' , 'id', $db); } } ?> - Add "jos_hello_comment" table. It have 6 fields.
Click Go button.
- Enter fields like following images:
- Set primary key on id field:
- Click Save button.
If you prefer SQL command, you can execute the following code:
CREATE TABLE `jos_hello_comment` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `hello_id` INT( 11 ) NOT NULL , `user_id` INT( 11 ) NOT NULL , `full_name` VARCHAR( 50 ) NOT NULL , `comment_date` DATETIME NOT NULL , `comment_text` TEXT NOT NULL ) ENGINE = MYISAM ;

