如何创建一个MVC模式的Joomla组件教程(十三) - 创建管理员界面Hellos Template

Hellos Template

模板获取view传递的数据,并生成输出。我们用一个表格显示输出,尽管前台的模板非常简单,可是后台的管理复杂一些从而能处理数据。

这是 views/hellos/tmpl/default.php的代码清单 :

<?php defined('_JEXEC') or die('Restricted access'); ?>
<form action="index.php" method="post" name="adminForm">
<div id="editcell">
    <table class="adminlist">
    <thead>
        <tr>
            <th width="5">
                <?php echo JText::_( 'ID' ); ?>
            </th>
            <th>
                <?php echo JText::_( 'Greeting' ); ?>
            </th>
        </tr>           
    </thead>
    <?php
    $k = 0;
    for ($i=0, $n=count( $this->items ); $i < $n; $i++)
    {
        $row =& $this->items[$i];
        ?>
        <tr class="<?php echo "row$k"; ?>">
            <td>
                <?php echo $row->id; ?>
            </td>
            <td>
                <?php echo $row->greeting; ?>
            </td>
        </tr>
        <?php
        $k = 1 - $k;
    }
    ?>
    </table>
</div>

<input type="hidden" name="option" value="com_hello" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="controller" value="hello" />

</form>

你看到我们的输出用一个form包含,现在并不是必须的,但是以后有用处。


以下是新增的5个文件,你可以把这些文件添加到xml中,并试试。

admin.hello.php
controller.php
models/hellos.php
views/hellos/view.html.php
views/hellos/tmpl/default.php

posted on 2009-12-26 22:02  14的路  阅读(394)  评论(0编辑  收藏  举报

导航

友情链接:源码下载