Luyenkim.Net!

...where your idea grows!

 
  • Decrease font size
  • Default font size
  • Increase font size
Trang chủ arrow Công nghệ thông tin arrow HTML Output Class Redefined
HTML Output Class Redefined PDF Print E-mail
(0 votes)
Thứ sáu, 23 Tháng một 2007
Article Index
HTML Output Class Redefined
Continued
Introduction
Not long ago, I got tired of passing certain common variables to every output function. So I decided to incorporate them into my output class instead. If you're familiar with the general layout of a typical output class, then what I'm about to present should make a lot of sense. I hope these examples will help you out along the way as you continue to contribute to the Mambo open source community.
The Old Way

Let's take a look at how the typical output class works. Normally, we call a function that collects the data we want displayed to the user. Then we call an HTML output class function to display the data.

The Logic

Here's a typical logic function. Notice how many variables are passed to the output function. In many cases, we always pass a few of the same variables to our output class. And each time we create a new output function, we have to remember to pass those same variables.

function myFunction( $id, $option, $task, $Itemid ) {	
global $my, $mosConfig_live_site;
// do some processing
$id = (int)$id;
$name = $my->name;
// output our data
HTML_myOutput::show($id, $name, $option, $Itemid, $mosConfig_live_site);
}
The Output

Here's a typical output class. And there's those pesky common variables again. They're the same for just about every output function we write. And they're a pain to keep up with if we have multiple output functions.

<?php
class HTML_myOutput {
function show( $id, $name, $option, $Itemid, $mosConfig_live_site ) {
?>
<p>Hello, <?php echo $name<br />
<p>The value for $id is <?php echo $id; ?></p>
<p> </p>
<p>
<a href="<?php echo "$mosConfig_live_site/index.php&option=$option&Itemid=$Itemid"; ?>">
Return to My Component</a></p>
<?php
}
}
?>
A New Way

Have you ever spent time debugging your code only to discover you left out one of those common variables? Or maybe it was in the wrong order in the function parameter list and all kinds of strange things happened in your output.

Enter a new HTML output class. We'll be adding some new features that will help you keep those common variables straight.

Click the link below to continue your journey.




Related news items:
Newer news items:
Older news items:

 

Please install Flash and turn on Javascript.

Đăng nhập






Lost Password?
No account yet? Register

Liên kết website

vinaora.com
Luyenkim.net
joomlaviet.org
Trung tam ho tro giao vien
Sửa ĐTDD
buaxua.vn

Thống kê

We have 19 guests and 1 member online