What is the reason pagination of records its not working?

by user615274   Last Updated October 12, 2019 05:10 AM - source

Following the Developing an MVC Component / Basic backend guide, I can't make the pagination to work, following the instructions this is the code I have, the records are listed properly and the pagination component is drawn, but when I click on any of the pages the page browser scroll only goes up without redirecting. I welcome your suggestions

administrator/components/com_demo/views/demo/view.html.php

<?php

defined('_JEXEC') or die('Restricted access');

class DemoViewDemo extends JViewLegacy
{
    public function display($tpl = null)
    {
        $this->items = $this->get('Items');
        $this->pagination = $this->get('Pagination');

        if (count($errors = $this->get('Errors'))) {
            JError::raiseError(500, implode('<br />', $errors));

            return false;
        }

        $this->addToolBar();

        parent::display($tpl);
    }

    protected function addToolBar()
    {
        JToolbarHelper::title(JText::_('COM_DEMO_TITLE'));
    }
}

administrator/components/com_demo/models/demo.php

<?php

defined('_JEXEC') or die('Restricted access');

class DemoModelDemo extends JModelList
{
    protected function getListQuery()
    {
        $dbo = JFactory::getDbo();

        $query = $dbo->getQuery(true);

        $query->select('*')->from('#__demo');

        return $query;
    }
}

administrator/components/com_demo/views/demo/tmpl/default.php

<?php

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;

?>

<form action="index.php?option=com_demo&view=demo" method="post" id="adminForm" name="adminForm">
    <table class="table table-hover table-striped table-hover table-bordered">
        <thead>
            <tr>
                <th width="1%"></th>
                <th width="9%">item1</th>
                <th width="10%">item2</th>
                <th width="50%">item3</th>
                <th width="5%">item4</th>
                <th width="5%">item5</th>
                <th width="10%">item6</th>
                <th width="10%">item7</th>
            </tr>
        </thead>

        <tfoot>
            <tr>
                <td colspan="8">
                    <?= $this->pagination->getListFooter(); ?>
                </td>
            </tr>
        </tfoot>

        <tbody>
            <?php foreach ($this->items as $index => $item): ?>
                <tr>
                    <td>
                        <?= $this->pagination->getRowOffset($index); ?>
                    </td>
                    <td>
                        <?= $item->domain ?>
                    </td>
                    <td>
                        <?= $item->firstName ?>
                    </td>
                    <td>
                        <?= $item->lastName ?>
                    </td>
                    <td>
                        <?= $item->label ?>
                    </td>
                    <td>
                        <?= $item->location ?>
                    </td>
                    <td>
                        <?= HTMLHelper::_('date', $item->date_entered, JText::_('DATE_FORMAT_LC5')) ?>
                    </td>
                    <td>
                        <?= HTMLHelper::_('date', $item->date_modified, JText::_('DATE_FORMAT_LC5')) ?>
                    </td>
                </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
</form>
Tags : pagination


Related Questions


Changing look of pagination

Updated March 13, 2016 08:04 AM


Page break on my page shows as simple horizontal line

Updated December 05, 2016 08:04 AM