• Home
  • Support
  • Forum
  • Cobalt 8
  • Постраничная навигация, как уменьшить количество страниц?

COBALT
Total posts: 408
07 Sep 2015 12:01

На небольших мобильных устройствах постраничная навигация не помещается в одну строку, подскажите как уменьшить количество страниц с 10, например до 7?

Last Modified: 18 May 2016


COBALT
Total posts: 408
07 Sep 2015 16:45

Разобрался, это из самой Joomla берётся

в файле \libraries\cms\pagination\pagination.php нужно изменить значение $displayedPages = 10;, где 10 это количество страниц :)


COBALT
Total posts: 408
08 Sep 2015 07:54

Что то ещё править нужно, установил ограничение в 7 страниц $displayedPages = 7;, в результате при переходе на страницу 5, получаю такой результат:


COBALT
Total posts: 408
08 Sep 2015 08:01

Если установить чётное число 4, 6, 8 значения $displayedPages, тогда всё в порядке.


pepperstreet VIP
Total posts: 3,837
08 Sep 2015 12:33

Hello COBALT, never touched it in the last 10+ years... ;)
But isn't there a pagination.php override in YourTemplate/HTML/...
Maybe the better place to modify something.


Sergey
Total posts: 13,748
08 Sep 2015 14:11

pepperstreet But isn't there a pagination.php override in YourTemplate/HTML/...

Maybe the better place to modify something.

+1


COBALT
Total posts: 408
09 Sep 2015 07:35

В шаблоне \templates\yoo_avenue\html\pagination.php файл pagination.php выглядит так:

<?php
$base = dirname(__FILE__);
include($base.'/config.php');
include($warp['path']->path('layouts:'.preg_replace('/'.preg_quote($base, '/').'/', '', __FILE__, 1)));

И всё, в нём больше ни чего нет.


pepperstreet VIP
Total posts: 3,837
09 Sep 2015 10:03

COBALT yoo_avenue

Ah, I see. This is specific to Yootheme templates and WARP framework!
The WARP framework stores all Joomla (system) files inside their own framework subfolder.
They have to re-link the original location to their location.
They also change the default override location. It is no longer in /HTML... ;)
Here is the related WARP Override cascade:

Actually, you have even 2 important override locations in your template:

1. Styles folder
The /styles/STYLE-NAME/layouts folder of your theme is at the top of the hierarchy and modifications or additions you make here will override all other theme files. Also this folder will be preserved during updates, so it's the safest place to make your modifications.

2. Theme folder
The theme's /layouts

3. ...


Sergey
Total posts: 13,748
10 Sep 2015 06:31

Ничего там не поравишь. $list['pages'] уже содержит необходимое количество страниц. Этот параметр где то в другом месте прячется.

It looks like it is hardcoded in libraries/cms/pagination/pagination.php on line 144 $displayedPages = 10;.


COBALT
Total posts: 408
10 Sep 2015 08:06

Sergey It looks like it is hardcoded in libraries/cms/pagination/pagination.php on line 144 $displayedPages = 10;.

Всё верно, к сожалению корректно работает только чётное число страниц 2, 4, 6, 8 и т.д.

Я хотел установить отображение в 7 страниц, но после перехода на пятую и последующие страницы, получаю такую картину:

Придётся использовать чётное число.


Sergey
Total posts: 13,748
10 Sep 2015 08:15

Проблема только в числах? Отображет старници правильно? Нужно только поправить 2.5 на 2 и т.д?


COBALT
Total posts: 408
10 Sep 2015 08:23

Да, только в числах, ещё заметил что пропадает отображение на какой странице сейчас находиться пользователь, то есть цифра страницы должна быть серого цвета как на скриншоте:


Sergey
Total posts: 13,748
10 Sep 2015 10:28

Значит надо просто попробвать в файле pagination.php добавить

else if ((int)$item->text > 0) {
    $item->text = floor($item->text);
}

Sergey
Total posts: 13,748
14 Sep 2015 15:46

Там в список else if как еще одно условие.


COBALT
Total posts: 408
14 Sep 2015 16:22

Ошибок нет, но не работает, вставил условие вот сюда:

     /**
     * Create and return the pagination page list string, ie. Previous, Next, 1 2 3 ... x.
     *
     * @return  string  Pagination page list string.
     *
     * @since   1.5
     */
    public function getPagesLinks()
    {
        // Build the page navigation list.
        $data = $this->_buildDataObject();

        $list = array();
        $list['prefix'] = $this->prefix;

        $itemOverride = false;
        $listOverride = false;

        $chromePath = JPATH_THEMES . '/' . $this->app->getTemplate() . '/html/pagination.php';

        if (file_exists($chromePath))
        {
            include_once $chromePath;

            if (function_exists('pagination_item_active') && function_exists('pagination_item_inactive'))
            {
                $itemOverride = true;
            }

            if (function_exists('pagination_list_render'))
            {
                $listOverride = true;
            }
        }
        else if ((int)$item->text > 0) {
    $item->text = floor($item->text);
}


Sergey
Total posts: 13,748
15 Sep 2015 05:12

Видишь там есть else if в function pagination_item_active($item) {? Вот туда и надо.


COBALT
Total posts: 408
15 Sep 2015 10:34

Добавил, но ни чего не изменилось:

function pagination_item_active($item) {

        $cls = '';
        $title = '';

        if ($item->text == JText::_('JNEXT')) {
            $item->text = '<i class="uk-icon-angle-right"></i>';
            $cls = "next";
            $title = JText::_('JNEXT');
        }
        else if ($item->text == JText::_('JPREV')) {
            $item->text = '<i class="uk-icon-angle-left"></i>';
            $cls = "previous";
            $title = JText::_('JPREV');
        }
        else if ($item->text == JText::_('JLIB_HTML_START')) {
            $item->text = '<i class="uk-icon-angle-double-left"></i>';
            $cls = "first";
            $title = JText::_('JLIB_HTML_START');
        }
        else if ($item->text == JText::_('JLIB_HTML_END')) {
            $item->text = '<i class="uk-icon-angle-double-right"></i>';
            $cls = "last";
            $title = JText::_('JLIB_HTML_END');
        }
        else if ((int)$item->text > 0) {
            $item->text = floor($item->text);
        }


Sergey
Total posts: 13,748
16 Sep 2015 06:16

Ну я не знаю точно я предположил. Нужно просто посмотреть что там в этой переменно. Ну это можно исправить в этом файле точно.


COBALT
Total posts: 408
02 May 2016 09:26

Хочу немного пагинацию подправить, использовать CSS шаблона, сейчас пагинация выглядит так:

Мне нужно чтобы пагинация использовала CSS шаблона:

Подскажите в каком файле и какой код выводит пагинацию?


COBALT
Total posts: 408
02 May 2016 10:18

Нашёл где нужно изменить CSS \components\com_cobalt\views\records\tmpl\default_markup_default.php

<div style="text-align: center;" class="pagination"> <?php echo str_replace('<ul>', '<ul class="pagination-list">', $this->pagination->getPagesLinks()); ?> </div>

Только не могу найти где прописать класс CSS для активного элемента пагинации:


COBALT
Total posts: 408
02 May 2016 10:23

В общем так даже лучше выглядит, вопрос решён :)

Powered by Cobalt