Joomla - Component: a Hello page


After build list screen at front end, we want to display single data in a page. Now, we will build single page data with link to back frontpage.
  1. Open "hello.php", update with following code:
    switch( $task ){
      	case 'view':
        viewHello($option);
        break;
    
      default:
        showPublishedHello($option);
        break;
    }
    
  2. add viewhello() function:
    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);
    }
    
  3. Open "hello.html.php". Add following function after showhello():
    	function viewHello($row, $option)
    	{ ?>
      <p class="contentheading"><?php echo "ID: <b>". $row->id ."</b>";?></p>
      <p><?php echo "Message: <br><b>". $row->message . "</b>";?></p>  
    
      <?php $link = 'index.php?option='. $option; ?>
      <p><a href="<?php echo $link;?>">< return to the hello frontpage</a></p>  
      <?php
    	}
    


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

Bookmark and Share Tag: joomla, cms, Joomla Component Category: PHP Framework Post : November 08th 2007 Read: 51,960

advertisements


blog comments powered by Disqus