Jump to content


Photo
- - - - -

Список типов элемента в алфавитном порядке? Как?


Best Answer Cheren-dow , 07 July 2014 - 09:09

Гордей, доброго времени суток. Извините за долгий ответ.

Попробуйте внести следующие правки. Откройте файл

сайт\administrator\components\com_zoo\classes\application.php

Найдите в нем метод getTypes 

public function getTypes() {
...
}

И замените его полностью на 

public function getTypes() {

    if (empty($this->_types)) {

        $this->_types = array();
        $path   = $this->getResource() . '/types';
        $filter = '/^.*config$/';
        if ($files = $this->app->path->files($path, false, $filter)) {
            foreach ($files as $file) {
                $alias = basename($file, '.config');
                $this->_types[$alias] = $this->app->object->create('Type', array($alias, $this));
            }
        }

        usort($this->_types, array('Application', 'cmp'));
    }

    return $this->_types;
}

И ниже добавьте дополнительный метод

/**
 * @param $a
 * @param $b
 * @return int
 */
public function cmp($a, $b)
{
    return strcmp($a->name, $b->name);
}

После этого сортировка должна происходить в алфавитном порядке

Go to the full post


  • This topic is locked This topic is locked
1 reply to this topic

#1 Гордей

Гордей
  • JBZoo User (rus)
  • User rate: 0
  • posts: 60
  • topics: 28

Posted 02 July 2014 - 12:15

Как сделать так, чтобы при Создании нового элемента на этапе выбора типа элемента, список типов элемента был выведен в алфавитном порядке?

Attached Thumbnails

  • dddd.jpg

  • 0

#2 Cheren-dow

Cheren-dow
  • JBZoo User (rus)
  • User rate: 95.7
  • posts: 5060
  • topics: 31

Posted 07 July 2014 - 09:09   Best Answer

Гордей, доброго времени суток. Извините за долгий ответ.

Попробуйте внести следующие правки. Откройте файл

сайт\administrator\components\com_zoo\classes\application.php

Найдите в нем метод getTypes 

public function getTypes() {
...
}

И замените его полностью на 

public function getTypes() {

    if (empty($this->_types)) {

        $this->_types = array();
        $path   = $this->getResource() . '/types';
        $filter = '/^.*config$/';
        if ($files = $this->app->path->files($path, false, $filter)) {
            foreach ($files as $file) {
                $alias = basename($file, '.config');
                $this->_types[$alias] = $this->app->object->create('Type', array($alias, $this));
            }
        }

        usort($this->_types, array('Application', 'cmp'));
    }

    return $this->_types;
}

И ниже добавьте дополнительный метод

/**
 * @param $a
 * @param $b
 * @return int
 */
public function cmp($a, $b)
{
    return strcmp($a->name, $b->name);
}

После этого сортировка должна происходить в алфавитном порядке


  • 1
Изображение
 




Click to return to top of page in style!