it-swarm-id.com

Masalah Pagination Joomla dengan Kerangka K2 + sh404SEF + T3

Tampaknya ada masalah dengan pagination K2 di Joomla saat menggunakan sh404SEF + T3 Framework!

Url halaman tidak dihasilkan dengan benar!

Ketika saya pergi ke Halaman 2 saya masih perlu url mydomain.com/Halaman-1

Setiap saran cara memperbaiki bug pagination ini di T3. Saya yakin pagination dihasilkan oleh T3, karena ketika saya mengubah template frontend pagination berfungsi dengan baik!

Terima kasih!

2
Gev Balyan

Ini memang bug T3! Itu tidak menghasilkan url yang benar untuk pagination kategori K2.

Untuk memperbaikinya, silakan ikuti panduan sederhana ini:

  1. Pergi ke plugin/sistem/t3/include/joomla30
  2. Edit file pagination.php
  3. Pergi ke baris 688 dan ubah ke: $data->start->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=0&limit='.$this->limit);
  4. Pergi ke baris 69 dan ubah ke: data->previous->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $page.'&limit='.$this->limit);
  5. Pergi ke baris 7 dan ubah ke: $data->next->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $next.'&limit='.$this->limit);
  6. Pergi ke baris 705 dan ubah ke: $data->end->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $end.'&limit='.$this->limit);

Dalam satu kata: tambahkan berikut ini (&limit=$this->limit) sampai akhir baris yang disebutkan di atas (tanpa tanda kurung)

Setelah melakukan langkah-langkah yang dijelaskan, jangan lupa untuk menghapus halaman blog dari sh404SEF URL Manager dan menghapus cache Joomla!

Semoga ini membantu!

1
Gev Balyan

Ini bukan masalah K2, T3 atau sh404 sef. Ini adalah bug Joomla. batas hilang dari T3 url, dan K2 hanya mengesampingkan metode JPagination default dan _buildDataObject metode dalam kelas JPagination tidak memiliki &limit=$this->limit. sh404sef sedang mencoba untuk memperbaikinya tetapi T3 atau K2 menimpa api sebelum sh404 sef

di sini adalah perbaikan untuk 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;
}

dan yang ini untuk 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;
}
1
Dan