SEQUEL.ONE

SEQUEL.ONE

Был в сети 30 июня 2026, 13:59
Заказы принимаю
Что-то я въехать не могу, добавил код:

<?php

class modExtraItemGetListProcessor extends modObjectGetListProcessor
{
    public $objectType = 'modExtraItem';
    public $classKey = 'modExtraItem';
    public $defaultSortField = 'id';
    public $defaultSortDirection = 'DESC';
    protected $productsList = [];
    //public $permission = 'list';

    /**
     * @return bool
     */
    public function initialize()
    {
        if ($this->getProperty('combo') && !$this->getProperty('limit') && $id = (int)$this->getProperty('id')) {
            $this->item_id = $id;
        }

        return true;
    }

    /**
     * We do a special check of permissions
     * because our objects is not an instances of modAccessibleObject
     *
     * @return boolean|string
     */
    public function beforeQuery()
    {
        if (!$this->checkPermissions()) {
            return $this->modx->lexicon('access_denied');
        }

        return true;
    }


    /**
     * @param xPDOQuery $c
     *
     * @return xPDOQuery
     */
    public function prepareQueryBeforeCount(xPDOQuery $c)
    {
        $query = trim($this->getProperty('query'));

        $c->leftJoin('modExtraCategory', 'modExtraCategory', 'modExtraCategory.id = modExtraItem.category_id');
        $c->select(array($this->modx->getSelectColumns('modExtraItem', 'modExtraItem')));
        $c->select(array('modExtraCategory.name as category_name'));

        $c->leftJoin('modUser', 'modUser', 'modUser.id = modExtraItem.createdby');
        $c->select(array($this->modx->getSelectColumns('modExtraItem', 'modExtraItem')));
        $c->select(array('modUser.username as createdby_name'));

        $item = $this->modx->getObject('modExtraItem', 'modExtraItem.id');
        $products = $item->get('products');

        $q = $this->modx->newQuery('modResource');
        $q->where(array('id:IN' => $products));
        $q->select(array('id','pagetitle'));
        if($q->prepare() && $q->stmt->execute()) {
            $this->productsList = $q->stmt->fetchAll(PDO::FETCH_ASSOC);
        }

        if ($query) {
            $c->where([
                'name:LIKE' => "%{$query}%",
                'OR:category_id:LIKE' => "%{$query}%"
            ]);
        }

        return $c;
    }


    /**
     * @param xPDOObject $object
     *
     * @return array
     */
    public function prepareRow(xPDOObject $object)
    {
        $array = $object->toArray();
        $array['actions'] = [];

        // Edit
        $array['actions'][] = [
            'cls' => '',
            'icon' => 'icon icon-edit',
            'title' => $this->modx->lexicon('modextra_item_update'),
            //'multiple' => $this->modx->lexicon('modextra_items_update'),
            'action' => 'updateItem',
            'button' => true,
            'menu' => true,
        ];

        if (!$array['active']) {
            $array['actions'][] = [
                'cls' => '',
                'icon' => 'icon icon-power-off action-green',
                'title' => $this->modx->lexicon('modextra_item_enable'),
                'multiple' => $this->modx->lexicon('modextra_items_enable'),
                'action' => 'enableItem',
                'button' => true,
                'menu' => true,
            ];
        } else {
            $array['actions'][] = [
                'cls' => '',
                'icon' => 'icon icon-power-off action-gray',
                'title' => $this->modx->lexicon('modextra_item_disable'),
                'multiple' => $this->modx->lexicon('modextra_items_disable'),
                'action' => 'disableItem',
                'button' => true,
                'menu' => true,
            ];
        }

        // Remove
        $array['actions'][] = [
            'cls' => '',
            'icon' => 'icon icon-trash-o action-red',
            'title' => $this->modx->lexicon('modextra_item_remove'),
            'multiple' => $this->modx->lexicon('modextra_items_remove'),
            'action' => 'removeItem',
            'button' => true,
            'menu' => true,
        ];

        return $array;
    }

    public function outputArray(array $array, $count = false)
    {
        return parent::outputArray($this->productsList, $count);
    }

}

return 'modExtraItemGetListProcessor';
В items.grid.js прописано

{
            header: _('modextra_products'),
            dataIndex: 'products',
            sortable: false,
            width: 150,
        },
Не отображается ничего



Вот это поле нужно подменять, но оставить id'шники в таблице. Таблица имеет название products.

Зачем? Я решил уже:

{'!pdoMenu' | snippet : [
                'parents' => '30,31,33,34,35',
                'displayStart' => 1,
                'context' => 'web,store,bezbflava,b1,sb1',
                'tplOuter' => '@INLINE <ul {$classes} data-scrollable="true">{$wrapper}</ul>',
                'outerClass' => 'navbar-nav',
                'tpl' => '@INLINE <li class="nav-item"><a href="{$link}" {$classes} {$attributes}><i class="la {$link_attributes}"></i><span>{$menutitle}</span></a>{$wrapper}</li>',
                'rowClass' => '{if $_modx->context.key != $_modx->resource.context}noajax{/if} nav-link',
                'tplStart' => '@INLINE <li class="nav-item nav-header">{$menutitle}</li>{$wrapper}',
                'level' => 2,
                'where' => [
                    'class_key:!=' => 'msProduct'
                ]
            ]}
Нужно добавить параметры:

'displayStart' => 1
и

'tplStart' => '@INLINE <li class="nav-item nav-header">{$menutitle}</li>{$wrapper}',
а в параметр parents вставить id's созданных документов и все пункты меню перетащить в эти разделы:

'parents' => '30,31,33,34,35',
Ну и на последок включить системную настройку:

use_frozen_parent_uris
а после у всех вложенных ресурсов второго уровня «Заморозить URI». Profit =)
{'!pdoMenu' | snippet : [
                'parents' => $_modx->resource.parent,
                'context' => $_modx->context.key,
                'tplOuter' => '@INLINE <ul {$classes} data-scrollable="true">{$wrapper}</ul>',
                'outerClass' => 'navbar-nav',
                'tpl' => '@INLINE <li class="nav-item"><a href="{$link}" {$classes} {$attributes}><i class="la {$link_attributes}"></i><span>{$menutitle}</span></a></li>',
                'rowClass' => 'nav-link',
                'level' => 1
            ]}
Вот так вроде выводит как надо.
store.sequel.one/packages/others/sonelandingpage/ — правда сам ключ в данный момент мы сгенерируем вам самостоятельно после вашей регистрации, сайт в разработке, но у нас свой репозиторий как в modstore.pro все обновления на сайте вы можете получать самостоятельно через админку.