Advertisement
Free Mambo Templates - Free Joomla Templates
Joomla Hut HomeContact UsJoomla LinksMambo Forum - Joomla ForumJoomla Downloads
Home
News
Articles
Gallery
Downloads
Tutorials
Site Reviews
Flash Tutorials
Templates Demo
Joomla Links
FAQ
Advertise Here
Search
Advertisement
Seek Your Host
New York Web Design
Joomla Templates
Login Form





Lost Password?
No account yet? Register
Joomla Extensions
Joomla Templates
TemplatePlazza
 
Joomla Website

Creating a quick and easy Mambo component Print E-mail
Written by Doyle Lewis   
Thursday, 15 April 2004

admin.hello_world.html.php - Handles all output.

<?php
//hello_world Component//
/**
* Content code
* @package hello_world
* @Copyright (C) 2004 Doyle Lewis
* @ All rights reserved
* @ hello_world is Free Software
* @ Released under GNU/GPL License :
http://www.gnu.org/copyleft/gpl.html
* @version 1.0
**/

// ensure this file is being included by a parent file
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

require_once($mosConfig_absolute_path."/administrator/components/com_hello_world/class.hello_world.php");

class HTML_hello_world {

function edit( $option, &$row ) {
?>
  <script language="javascript" type="text/javascript">
    function submitbutton(pressbutton) {
    var form = document.adminForm;
    if (pressbutton == "cancel") {
      submitform( pressbutton );
      return;
    }
    submitform( pressbutton );
    }
  </script>

<form action="index2.php" method="post" name="adminForm" id="adminForm" class="adminForm">
<table border="0" cellpadding="3" cellspacing="0">
 <tr>
  <td>Text Output: </td>
  <td><input type="text" size="50" maxsize="100" name="text" value="<?php echo $row->text; ?>" /></td>
 </tr>
</table>

<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="task" value="" />
</form>
<?php } ?>


function showText( $option, &$rows ) {
 ?>
  <script language="javascript" type="text/javascript">
  function submitbutton(pressbutton) {
    var form = document.adminForm;
    if (pressbutton == "cancel") {
      submitform( pressbutton );
      return;
    }
    submitform( pressbutton );
  }
  </script>
  <form action="index2.php" method="post" name="adminForm">
  <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
   <tr>
    <th width="20"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?>);" /></th>
    <th class="title" width="25%">Text Output</th>
    <th width="25%">Published</th>
   </tr>
  <?php
    $k = 0;
    for($i=0; $i < count( $rows ); $i++) {
    $row = $rows[$i];
   ?>
    <tr class="<?php echo "row$k"; ?>">
     <td><input type="checkbox" id="cb<?php echo $i;?>" name="id[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" /></td>
     <td><a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')"><?php echo $row->text; ?></a></td>
     <td align="center">
      <?php
       if ($row->published == "1") {
         echo "<img src="images/tick.png" border="0" />";
       } else {
         echo "<img src="images/publish_x.png" border="0" />";
       }
      ?>
     </td>
     <?php $k = 1 - $k; ?>
    </tr>
 
<?php } ?>
  <input type="hidden" name="option" value="<?php echo $option; ?>" />
  <input type="hidden" name="task" value="" />
  <input type="hidden" name="boxchecked" value="0" />
  </form>

 <?php }
}
 ?>

Now let's look at how the file works:

class HTML_hello_world {
Opens the HTML output class.

function edit( $option, &$row ) {
Opens the edit function. This will show the form used to create new entries and well as edit existing ones.

  <script language="javascript" type="text/javascript">
    function submitbutton(pressbutton) {
    var form = document.adminForm;
    if (pressbutton == "cancel") {
      submitform( pressbutton );
      return;
    }
    submitform( pressbutton );
    }
  </script>

This checks when you press any of the toolbar buttons. Any form validation can be performed here as well.

<form action="index2.php" method="post" name="adminForm" id="adminForm" class="adminForm">
You can copy this verbatem to any component. It has to have all of these tags to look and function properly.

<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="task" value="" />

The option and task fields are required for this to save or cancel correctly.

function showText( $option, &$rows ) {
This will create the list of the text entries.

    <th width="20"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?>);" /></th>
This will select all checkboxes on the page to make publishing or deleting quicker.

  <?php
    $k = 0;
    for($i=0; $i < count( $rows ); $i++) {
    $row = $rows[$i];

$k is used to create the rollover effect on the rows. The for statement runs through all of the results.

     <td><input type="checkbox" id="cb<?php echo $i;?>" name="id[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" /></td>
This will check the checkbox just for this row.

     <td><a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit)"><?php echo $row->text; ?></a></td>
This creates a link that will take you to the edit page when clicked.

      <?php
       if ($row->published == "1") {
         echo "<img src="images/tick.png" border="0" />";
       } else {
         echo "<img src="images/publish_x.png" border="0" />";
       }
      ?>

If the row is set to published, you will see a green checkmark, otherwise you will see a red x.

     <?php $k = 1 - $k; ?>
Sets $k equal to 1 minus itsself. If $k is 0, it will then equal 1, if it set to 1 it will then equal 0.

  <input type="hidden" name="boxchecked" value="0" />
This line is important otherwise the checkboxes will not function correctly.

 


 
< Prev   Next >
 
 
Joomla Jobs
 
 
Joomla Flash Tutorials
   
     
Home   |   Contact   |   Links   |   Forum   |   Downloads  |  Media Kit
 

© Copyright 2003 - 2006 by BUYHTTP, LLC. All rights reserved.
None of the text or images in this public website may be copied without the expressed written consent of the authors.
Powered By Joomla!

Joomla Top Sites - Your Primary Source of Joomla Traffic