Joomla后端分页不能在自定义MVC应用程序中工作



Joomla后端分页无法在自定义MVC应用程序中工作

显示页面总数,但不包括从分页中按下的任何控件。失败并运行回启动屏幕"/administrator/index.php? "Option = com_agmanage"

这很令人困惑,因为$this-> pagination-> getRowOffset($i);正确显示。

默认视图如下:

    <?php
/**
* @version 1.0
* @package agmanage 1.0.0
*/
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.view');
jimport('joomla.html.pane');
class agmanageViewConfiguration extends JView
{
    function display($tpl = null)
    {
        global $mainframe;
        JToolBarHelper::title('Agility Eye Management','agmanage');
        JSubMenuHelper::addEntry(JText::_('Results'), 'index.php?option=com_agmanage&view=memberships');
        JSubMenuHelper::addEntry(JText::_('View Dogs Handlers & Subscribers'), 'index.php?option=com_agmanage&view=transactions');
        JSubMenuHelper::addEntry(JText::_('Database Administration'), 'index.php?option=com_agmanage&view=configuration', true);
        JSubMenuHelper::addEntry(JText::_('Manage Users'), 'index.php?option=com_rsmembership&view=users');
        JSubMenuHelper::addEntry(JText::_('Back to Splashscreen'), 'index.php?option=com_agmanage', true);
        $task = JRequest::getVar('task','');    
        JToolBarHelper::apply();
        JToolBarHelper::save();
        JToolBarHelper::cancel();
        $config = agmanageHelper::getConfig();
        $this->assignRef('config', $config);
        $pane =& JPane::getInstance('Tabs', array(), true);
        $this->assignRef('pane', $pane);
        $this->assignRef('sortColumn', JRequest::getVar('filter_order','date'));
        $this->assignRef('sortOrder', JRequest::getVar('filter_order_Dir','DESC'));
        $this->assignRef('configuration', $this->get('configuration'));
        $this->assignRef('cache', $this->get('cache'));
        $this->assignRef('pagination', $this->get('pagination'));
        $filter_word = JRequest::getString('search', '');
        $this->assignRef('filter_word', $filter_word);
        parent::display($tpl);
    }
}

下面是它运行的模板($ tpl):

<?php
/**
* @version 1.0
* @package agmanage 1.0.0
*/
defined('_JEXEC') or die('Restricted access');
JHTML::_('behavior.tooltip');
?>
<form action="index.php?option=com_agmanage&view=configuration" method="post" name="adminForm" id="adminForm">
<?php
echo $this->pane->startPane('configuration-pane');
echo $this->pane->startPanel(JText::_('Edit Dogs'), 'configuration-patches');
?>
<div class="col100">
    <? /* START OF EDIT DOGS */?>
    <table class="adminform">
        <tr>
            <td width="100%">
                <?php echo JText::_( 'Search (By Dog name)' ); ?>
                <input type="text" name="search" id="search" value="<?php echo $this->filter_word; ?>" class="text_area" onChange="document.adminForm.submit();" />
                <button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
                <button onclick="this.form.getElementById('search').value='';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
            </td>
            <td nowrap="nowrap">&nbsp;</td>
        </tr>
    </table>
    <div id="editcell1">
        <table class="adminlist">
            <thead>
                <tr>
                    <th width="5"><?php echo JText::_( '#' ); ?></th>
                    <th><?php echo JText::_( 'Dog Name' ); ?></th>
                    <th width="100"><?php echo JText::_('Status'); ?></th>
                    <th width="5"><?php echo JText::_('ABC'); ?></th>
                    <th width="150"><?php echo JText::_('Club'); ?></th>
                    <th width="140"><?php echo JText::_('Usual Handler'); ?></th>
                    <th><?php echo JText::_('Subscriber'); ?></th>
                    <th width="5"><?php echo JText::_( 'Edit' ); ?></th>
                </tr>
            </thead>
    <?php
    $k = 0;
    $i = 0;
    $n = count($this->configuration);
    foreach ($this->configuration as $row)
    {
    ?>
        <tr class="row<?php echo $k; ?>">
            <td align="center"><?php echo $this->pagination->getRowOffset($i); ?></td>
            <td align="center"><?php echo $row->DogName; ?></td>
            <td align="center"><?php echo $row->StatusCode; ?></td>
            <td align="center">
            <?php 
            if ($row->ABC=="1")
                echo "Yes";
            else
                echo "No";
            ?>
            </td>
            <td align="center">
            <?php 
            $con = mysql_connect("**********************");
            if (!$con)
                {
                die('Could not connect: ' . mysql_error());
                }
                mysql_select_db("agilityeye", $con);
                $temp=$row->Clubcode;
                //echo $temp;
                $result = mysql_query("SELECT * FROM club WHERE Clubcode=$temp") or die(mysql_error());
                while($new = mysql_fetch_array($result))
                 {
                 echo $new['Club'];
                 }
                mysql_close($con);
            ?>
            </td>
            <td align="center"><?php 
            $con = mysql_connect("**********************");
            if (!$con)
                {
                die('Could not connect: ' . mysql_error());
                }
                mysql_select_db("agilityeye", $con);
                $temp=$row->HandlerId;
                //echo $temp;
                $result = mysql_query("SELECT * FROM handlers WHERE handlerId=$temp") or die(mysql_error());
                while($new1 = mysql_fetch_array($result))
                 {
                 echo $new1['HandlerFore'] . " " . $new1['HandlerSur'];
                 }
                mysql_close($con);
            ?></td>
            <td align="center"><?php 
            $con = mysql_connect("**********************");
            if (!$con)
                {
                die('Could not connect: ' . mysql_error());
                }
                mysql_select_db("agilityeye", $con);
                $temp=$row->Subcode;
                echo $temp;
                $result = mysql_query("SELECT * FROM jos_users WHERE calluser=$temp") or die(mysql_error());
                while($new2 = mysql_fetch_array($result))
                 {
                 echo " - ";
                 echo $new2['name'];     
                 }
                mysql_close($con);
            ?></td>
            <td><a href="<?php //echo JRoute::_('index.php?option=com_agmanage&controller=configuration&task=edit&handler='.$row->Subcode.'&dog='.$row->Dogcode); ?>"><IMG src="http://www.agilityeye.co.uk.juliet.webhoster.co.uk/images/M_images/edit.png"></a></td>
        </tr>
    <?php
        $i++;
        $k=1-$k;
    }
    ?>
        <tfoot>
            <tr>
                <td colspan="12"><?php echo $this->pagination->getListFooter(); ?></td>
            </tr>
        </tfoot>
        </table>
    </div>
    <?php echo JHTML::_( 'form.token' ); ?>
    <input type="hidden" name="boxchecked" value="0" />
    <input type="hidden" name="option" value="com_agmanage" />
    <input type="hidden" name="view" value="configuration" />
    <input type="hidden" name="controller" value="configuration" />
    <input type="hidden" name="task" value="" />
    <? /* END OF EDIT DOGS */?>
    </fieldset>
</div>
<div class="clr"></div>
<?php
echo $this->pane->endPanel();
echo $this->pane->startPanel(JText::_('New Tab'), 'new');
?>
<div class="col100">
    <fieldset class="adminform">
        <table class="admintable">
        <tr> Spacer</tr>
        </table>
    </fieldset>
</div>
<div class="clr"></div>
<?php
echo $this->pane->endPanel();
echo $this->pane->endPane();
?>
<?php echo JHTML::_('form.token'); ?>
<input type="hidden" name="option" value="com_agmanage" />
<input type="hidden" name="view" value="agmanage" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="configuration" />
</form>
<script type="text/javascript">
function rsm_enable_registration(what)
{
    if (what == 1)
        $('registration_page').disabled = false;
    else
        $('registration_page').disabled = true;
}
</script>
<?php
//keep session alive while editing
JHTML::_('behavior.keepalive');
?>

And the Model:

        <?php
        /**
        * @version 1.0
        * @package agmanage 1.0.0
        */
        defined('_JEXEC') or die('Restricted access');
        jimport('joomla.application.component.model');
        class agmanageModelConfiguration extends JModel
{
    var $_data = null;
    var $_total = 0;
    var $_query = '';
    var $_pagination = null;
    var $_db = null;
    var $_id = 0;
    function __construct()
    {
        parent::__construct();
        $this->_db = JFactory::getDBO();
        $this->_query = $this->_buildQuery();
        global $mainframe, $option;
        // Get pagination request variables
        $limit = $mainframe->getUserStateFromRequest($option.'.configuration.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
        $limitstart = $mainframe->getUserStateFromRequest($option.'.configuration.limitstart', 'limitstart', 0, 'int');
        // In case limit has been changed, adjust it
        $limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0);
        $this->setState($option.'.configuration.limit', $limit);
        $this->setState($option.'.configuration.limitstart', $limitstart);
    }
    function _buildQuery()
    {
        global $mainframe;
        //$query = "SELECT t.*, IFNULL(u.email, t.user_email) AS email FROM #__agmanage_configuration t LEFT JOIN #__users u ON (`t`.`user_id`=`u`.`id`)";
        $query = "SELECT * FROM dog";
        $filter_word = JRequest::getString('search', '');
        if (!empty($filter_word))
            $query .= " WHERE DogName LIKE '%".$filter_word."%'";
        /*
        $sortColumn = JRequest::getVar('filter_order', 'date');
        $sortColumn = $this->_db->getEscaped($sortColumn);
        $sortOrder = JRequest::getVar('filter_order_Dir', 'DESC');
        $sortOrder = $this->_db->getEscaped($sortOrder);
        $query .= " ORDER BY ".$sortColumn." ".$sortOrder;
        */
        return $query;
    }
    function getConfiguration()
    {
        global $option;
        if (empty($this->_data))
            $this->_data = $this->_getList($this->_query, $this->getState($option.'.configuration.limitstart'), $this->getState($option.'.configuration.limit'));
        return $this->_data;
    }
    function getTotal()
    {
        if (empty($this->_total))
            $this->_total = $this->_getListCount($this->_query); 
        return $this->_total;
    }
    function getPagination()
    {
        if (empty($this->_pagination))
        {
            global $option;
            jimport('joomla.html.pagination');
            $this->_pagination = new JPagination($this->getTotal(), $this->getState($option.'.configuration.limitstart'), $this->getState($option.'.configuration.limit'));
        }
        return $this->_pagination;
    }
    function remove($cids)
    {
        $cids = implode(',', $cids);
        $query = "DELETE FROM #__agmanage_configuration WHERE `id` IN (".$cids.")";
        $this->_db->setQuery($query);
        $this->_db->query();
        return true;
    }
    function getCache()
    {
        return agmanageHelper::getCache();
    }
        }
        ?>

如果你删除分页,一切显示正确吗?首先确保它在没有分页的情况下也能工作,这样您就不会去寻找一个不存在的问题。如果没有,那么在Joomla文档中逐步实现- http://docs.joomla.org/Using_JPagination_in_your_component

最新更新