phpeveryday.com

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


Joomla - Component: Adding Comment ( Displaying Comments )

Tag: joomla, cms   Category:
post: 13 Nov 2007 read: 2,777


This is last tutorial about adding comment at Joomla component. We will display list of comment below single posting (like usual blog, this site too).

  1. Open "hello.php" within joomla/components. Update viewHello() function with following bold code:
    
    function viewHello($option)
    {
      $id = JRequest::getVar('id', 0);
      $row =& JTable::getInstance( 'hello', 'Table');
      $row->load($id);
    	
      if(!$row->published)
      {
        JError::raiseError( 404, JText::_('Invalid ID Provided'));		
      }
      HTML_hello::viewHello($row, $option);
    
      $db =& JFactory::getDBO();
      $db->setQuery("SELECT * FROM #__hello_comment WHERE hello_id='$id'");
    	
      $rows = $db->loadObjectList();
    	
      foreach($rows as $row)
      {
        HTML_hello::showComment($row);
      }
    
      $user =& JFactory::getUser();
      if($user->name)
      {
        $name = $user->name;
      }
      else
      {
        $name = '';
      }
      HTML_hello::showCommentForm($option, $id, $name);
    
    }
    
  2. Open "hello.html.php", enter following function:
    
    	function showComment($row)
    	{
    	?>
      <P>
      <strong><?php echo $row->full_name; ?></strong>
      <em><?php echo JHTML::Date($row->comment_date); ?></em>
      </P>
      <P><?php echo $row->comment_text; ?></P>
        <?
    	}
    


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 ( Displaying Comments ):

This is very best tutorial for bigning.

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


615
posting