2

There seems to be an issue with the K2 pagination in Joomla when using sh404SEF + T3 Framework!

The urls of the pages are not generated correctly!

When I go to Page 2 it still takes me to url mydomain.com/Page-1

Any suggestion how to fix this pagination bug in T3. I am sure that the pagination is generated by T3, because when I change the frontend template the pagination works just fine!

Thank you!

1

This is indeed a T3 bug! It doesn't generate right urls for the K2 category's pagination.

To fix this, please follow this simple guide:

  1. Go to plugins/system/t3/includes/joomla30
  2. Edit the pagination.php file
  3. Go to line 688 and change it to: $data->start->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=0&limit='.$this->limit);
  4. Go to line 690 and change it to: data->previous->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $page.'&limit='.$this->limit);
  5. Go to line 703 and change it to: $data->next->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $next.'&limit='.$this->limit);
  6. Go to line 705 and change it to: $data->end->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $end.'&limit='.$this->limit);

In one word: add the following (&limit=$this->limit) to the end of the above mentioned lines (without brackets)

After performing the steps described, please don't forget to delete the blog pages from sh404SEF URL Manager and to clear the Joomla cache!

Hope this helps!

2
  • I would also suggest you contact the T3 Framework and/or K2 developers and mention this issue to them so they can release an update with a fix.
    – Lodder
    May 26 '14 at 22:37
  • Nice work finding the solution Gev!
    – Craig
    May 27 '14 at 0:25
1

It is not K2, T3 or sh404 sef problem. It is Joomla bug. limit is missing from url's T3, and K2 are only overriding default JPagination methods and _buildDataObject method in JPagination class is missing the &limit=$this->limit. sh404sef is trying to fix it but T3 or K2 override fire before sh404 sef

here is fix for J3x _buildDataObject

/**
 * Create and return the pagination data object.
 *
 * @return  object  Pagination data object.
 *
 * @since   1.5
 */
protected function _buildDataObject()
{
    $data = new stdClass;

    $limitString = '&limit=' . $this->limit; // sh404 fix
    // Build the additional URL parameters string.
    $params = '';

    if (!empty($this->additionalUrlParams))
    {
        foreach ($this->additionalUrlParams as $key => $value)
        {
            $params .= '&' . $key . '=' . $value;
        }
    }

    $data->all = new JPaginationObject(JText::_('JLIB_HTML_VIEW_ALL'), $this->prefix);

    if (!$this->viewall)
    {
        $data->all->base = '0';
        $data->all->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=');
    }

    // Set the start and previous data objects.
    $data->start = new JPaginationObject(JText::_('JLIB_HTML_START'), $this->prefix);
    $data->previous = new JPaginationObject(JText::_('JPREV'), $this->prefix);

    if ($this->pagesCurrent > 1)
    {
        $page = ($this->pagesCurrent - 2) * $this->limit;

        // Set the empty for removal from route
        // @todo remove code: $page = $page == 0 ? '' : $page;

        $data->start->base = '0';
        $data->start->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=0');
        $data->previous->base = $page;
        $data->previous->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $page. $limitString);
    }

    // Set the next and end data objects.
    $data->next = new JPaginationObject(JText::_('JNEXT'), $this->prefix);
    $data->end = new JPaginationObject(JText::_('JLIB_HTML_END'), $this->prefix);

    if ($this->pagesCurrent < $this->pagesTotal)
    {
        $next = $this->pagesCurrent * $this->limit;
        $end = ($this->pagesTotal - 1) * $this->limit;

        $data->next->base = $next;
        $data->next->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $next . $limitString);
        $data->end->base = $end;
        $data->end->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $end . $limitString);
    }

    $data->pages = array();
    $stop = $this->pagesStop;

    for ($i = $this->pagesStart; $i <= $stop; $i++)
    {
        $offset = ($i - 1) * $this->limit;

        $data->pages[$i] = new JPaginationObject($i, $this->prefix);

        if ($i != $this->pagesCurrent || $this->viewall)
        {
            $data->pages[$i]->base = $offset;
            $data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset . $limitString);
        }
        else
        {
            $data->pages[$i]->active = true;
        }
    }

    return $data;
}

and this one is for 2.5.x

/**
 * Create and return the pagination data object.
 *
 * @return  object  Pagination data object.
 *
 * @since   11.1
 */
protected function _buildDataObject()
{
    // Initialise variables.
    $data = new stdClass;

    $limitString = '&limit=' . $this->limit; // sh404 fix

    // Build the additional URL parameters string.
    $params = '';
    if (!empty($this->_additionalUrlParams))
    {
        foreach ($this->_additionalUrlParams as $key => $value)
        {
            $params .= '&' . $key . '=' . $value;
        }
    }

    $data->all = new YjsgJPaginationDefaultObject(JText::_('JLIB_HTML_VIEW_ALL'), $this->prefix);
    if (!$this->_viewall)
    {
        $data->all->base = '0';
        $data->all->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=');
    }

    // Set the start and previous data objects.
    $data->start = new YjsgJPaginationDefaultObject(JText::_('JLIB_HTML_START'), $this->prefix);
    $data->previous = new YjsgJPaginationDefaultObject(JText::_('JPREV'), $this->prefix);

    if ($this->get('pages.current') > 1)
    {
        $page = ($this->get('pages.current') - 2) * $this->limit;

        // Set the empty for removal from route
        //$page = $page == 0 ? '' : $page;

        $data->start->base = '0';
        $data->start->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=0');
        $data->previous->base = $page;
        $data->previous->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $page . $limitString);
    }

    // Set the next and end data objects.
    $data->next = new YjsgJPaginationDefaultObject(JText::_('JNEXT'), $this->prefix);
    $data->end = new YjsgJPaginationDefaultObject(JText::_('JLIB_HTML_END'), $this->prefix);

    if ($this->get('pages.current') < $this->get('pages.total'))
    {
        $next = $this->get('pages.current') * $this->limit;
        $end = ($this->get('pages.total') - 1) * $this->limit;

        $data->next->base = $next;
        $data->next->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $next . $limitString);
        $data->end->base = $end;
        $data->end->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $end . $limitString);
    }

    $data->pages = array();
    $stop = $this->get('pages.stop');
    for ($i = $this->get('pages.start'); $i <= $stop; $i++)
    {
        $offset = ($i - 1) * $this->limit;
        // Set the empty for removal from route
        //$offset = $offset == 0 ? '' : $offset;

        $data->pages[$i] = new YjsgJPaginationDefaultObject($i, $this->prefix);
        if ($i != $this->get('pages.current') || $this->_viewall)
        {
            $data->pages[$i]->base = $offset;
            $data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset . $limitString);
        }
    }
    return $data;
}
0

Re-fixed in 2021 after the "joomla4" pagination.php file from the T3 plugin suddenly started firing:

https://www.covingtoncreations.com/blog/solution-for-pagination-bug-w-joomla-3-k2-sh404sef-t3-framework

1
  • Thank you for sharing this find, but this type of answer is not sought by Stack Exchange communities. A link-only answer is only valuable while the link is working. If the destination page is moved or the site dies, then so dies this answer. Answers should always contain insights which are hard-written (there is nothing wrong with including links and attribution is required when quoting a foreign source). If you only wish to drop a link, you may make a comment under the question when you have unlocked the privilege.
    – mickmackusa
    Feb 12 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.