سؤال

I used the same code (below) in both front and backend, but the pagination is not working in the admin side.

====================MODEL=PART===========================

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;
}

}

====================VIEW=PART===========================

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);
    }
}

==================TEMPLATE=PART=========================

<?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>

This works fine in the front end (site side). Session output-> [orders] => stdClass Object ( [ordercol] => [limitstart] => 0 ) Link html/url (for next button)-> <a title="Next" href="/NewJoomla/index.php/component/ciie/?view=other&amp;start=20" class="pagenav">Next</a>

I put the same code in Admin side (backend), and it shows all the paginatiion buttons and everything. But the buttons don't function at all. They simple take me to the top of the page. When I check the links (for example 'next' button) I see this:

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

(As you can see href attribute value is empty(#).)

Session output-> [orders] => stdClass Object ( [ordercol] => ) (Here also 'limitstart' value doesn't exist at all.

I tried this in different fresh Joomla installations too but the same problems repeats again.

Is there any thing I missed?

هل كانت مفيدة؟

المحلول

Finally I sorted it out! It was a silly mistake!

In the template, I didn't put the list content inside a <form> tag. getListFooter() function shows the pagination buttons, but when clicked the action is not submitted anywhere. I corrected the code as shown below and it worked.

==========TEMPLATE=PART====================

...
    <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>

Thank you all.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top