phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Joomla - Component: Adding Comment ( Create Table )

Tag: joomla, cms   Category: PHP Framework
post: 13 Nov 2007 read: 5,163


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!

  1. 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);
      }
    }
    ?>
    
  2. Add "jos_hello_comment" table. It have 6 fields.
    Click Go button.
  3. Enter fields like following images:
  4. Set primary key on id field:
  5. 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 ;
    
    


Series this article:
Joomla - Component: Create Hello World Component on Front End
Joomla - Component: Create Hello World Component on Back End
Joomla - Component: Registering Your Component in database
Joomla - Component: Create Component Link for Front End
Joomla - Component: Creating Toolbars
Joomla - Component: Available Toolbar Buttons
Joomla - Component: Creating the Database Table
Joomla - Component: Creating Form Input Data at Back End
Joomla - Component: Saving Data to Database
Joomla - Component: Creating a List Screen
Joomla - Component: Creating Advance List Screen
Joomla - Component: Editing Data
Joomla - Component: Deleting Data
Joomla - Component: Updating publish state
Joomla - Component: Hello From Database at Front End
Joomla - Component: a Hello page
Joomla - Component: Generating Friendly Links
Joomla - Component: Adding Comment ( Create Table )
Joomla - Component: Adding Comment (Create Form)
Joomla - Component: Adding Comment ( Insert Data )
Joomla - Component: Adding Comment ( Displaying Comments )
Joomla: Fast Road to Understand Component Programming

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

1 Responses to Joomla - Component: Adding Comment ( Create Table ):

this is very very good article.
any code add in to index.php
there is some problem in insert the comment in to database.

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting