1

我在前端和后端都使用了相同的代码(如下),但分页在管理端不起作用。

====================模型=部分===========================

defined('_JEXEC') or die;

jimport('joomla.application.component.modellist');

class CiieModelOrders extends JModelList
{
    public function getItems()

{
    // Invoke the parent getItems method to get the main list
    $items = parent::getItems();

    return $items;
}

protected function getListQuery()
{
    $db     = $this->getDbo();
    $query  = $db->getQuery(true);

    $query->select('title');
    $query->from('q2b7v_menu');

    return $query;
}

}

====================查看=部分===========================

defined('_JEXEC') or die;

jimport('joomla.application.component.view');

class CiieViewOrders extends JView {

protected $state;
protected $item;
protected $form;
protected $params;

public function display($tpl = null) {

    $items = $this->get('Items');
    $pagination = $this->get('Pagination');

    $this->items = $items;
    $this->pagination = $pagination;

    parent::display($tpl);
    }
}

==================模板=部分=========================

<?php
JHtml::_('behavior.keepalive');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');

//Load admin language file
$lang = JFactory::getLanguage();
$lang->load('com_ciie', JPATH_ADMINISTRATOR);

?>
<div>
    <table>
    <?php
    foreach($this->items as $item){
        echo "<tr><td>".$item->title."</td></tr>";
    }
    ?>
</table>
<?php echo $this->pagination->getListFooter(); ?>
</div>

这在前端(站点端)工作正常。会话输出->[orders] => stdClass Object ( [ordercol] => [limitstart] => 0 ) 链接 html/url(用于下一个按钮)-> <a title="Next" href="/NewJoomla/index.php/component/ciie/?view=other&amp;start=20" class="pagenav">Next</a>

我将相同的代码放在管理端(后端),它显示了所有的分页按钮和所有内容。但是按钮根本不起作用。他们简单地将我带到页面顶部。当我检查链接(例如“下一步”按钮)时,我看到:

<a href="#" title="Next" onclick="document.adminForm.limitstart.value=20; Joomla.submitform();return false;">Next</a>

(如您所见,href 属性值为空(#)。)

会话输出-> [orders] => stdClass Object ( [ordercol] => ) (这里也根本不存在“limitstart”值。

我也在不同的新 Joomla 安装中尝试过这个,但同样的问题再次出现。

有什么我错过的吗?

4

1 回答 1

2

最后我整理好了!这是一个愚蠢的错误!

在模板中,我没有将列表内容放在<form>标签内。getListFooter() 函数显示分页按钮,但是当单击时,该操作不会在任何地方提交。我更正了如下所示的代码并且它有效。

==========模板=部分====================

...
    <div>
<form action="<?php echo JRoute::_('index.php?option=com_ciie&view=orders'); ?>" method="post" name="adminForm">
        <table>
        <?php
        foreach($this->items as $item){
            echo "<tr><td>".$item->title."</td></tr>";
        }
        ?>
    </table>
    <?php echo $this->pagination->getListFooter(); ?>
</form>
    </div>

谢谢你们。

于 2013-09-06T07:35:13.613 回答