Дмитрий

Дмитрий

С нами с 16 января 2018; Место в рейтинге пользователей: #928

phpThumbOn выводит заглушку

Хочу слезть с pthumb, т.к. она чёт не поддерживается более, а в phpThumbOn написано, что он скоростной.
Меняю… Выводит картинку заглушки. Не понимаю в чём соль.
<img class="activator" src="[[!pthumb? &input=`{$_pls['tv.photo_team_member'] != NULL ? $_pls['tv.photo_team_member'] : 'https://pp.userapi.com/c626719/v626719296/12a60/uwn8cZKKIqM.jpg'}` &options=`w=500&h=500&zc=T`]]">
<img class="activator" src="[[*photo_team_member:phpthumbon=`w=500&h=500&zc=1`]]">
Писал и такой запрос… [[phpthumbon? &input=`{$_pls['tv.photo_team_member']}` &options=`w=500&h=500&zc=T`]]
Помогите решить.
Дмитрий
22 февраля 2018, 08:58
modx.pro
1 299
0

Проблемы со сниппетом

Возникли проблемы с API.
В сниппете не я не указывал версию, по которой запрашивали с VK. Вроде как выдавало старой версией.
Сейчас смотрю. Не выводятся результаты.

Тогда
Посмотрел, что в echo query;
Результат:
{«error»:{«error_code»:8,«error_msg»:«Invalid request: v (version) is required»,«request_params»:[{«key»:«oauth»,«value»:«1»},{«key»:«method»,«value»:«photos.get»},{«key»:«owner_id»,«value»:"-85317162"},{«key»:«album_id»,«value»:«244474587»},{«key»:«rev»,«value»:«1»},{«key»:«extended»,«value»:«0»},{«key»:«feed_type»,«value»:«photo»},{«key»:«count»,«value»:""}]}}
Вот я думаю он ругается на версию.
Написал в строку
$query = file_get_contents('https://api.vk.com/method/photos.get?owner_id=-'.$owner_id.'&album_id='.$album_id.'&rev='.$rev.'&extended='.$extended.'&feed_type='.$feed_type.'&count='.$count.'&v=5.73');
последнюю версию.
Тогда результат есть prntscr.com/ihu6qr

Убираю echo $query; и страница вешается HTTP ERROR 500.

Вот такой код. Упрощённая код для теста.
<?php
// VK API
    $owner_id = $modx->getOption('owner_id', $scriptProperties, '85317162'); // Группа
    $album_id = $modx->getOption('album_id', $scriptProperties, '244474587'); // Альбом
    $rev = $modx->getOption('rev', $scriptProperties, '1'); // 1 новые сверху
    $extended = $modx->getOption('extended', $scriptProperties, '0'); // Расширенные поля
    $feed_type = $modx->getOption('feed_type', $scriptProperties, 'photo'); // photo, photo_tag
    $count = $modx->getOption('count', $scriptProperties, ''); // Количество загружаемых фото
    $class = $modx->getOption('class', $scriptProperties, '');
    $tpl = $modx->getOption('tpl', $scriptProperties, '@INLINE <li><img src="[[+photo_75]]"></li>');
    
    $query = file_get_contents('https://api.vk.com/method/photos.get?owner_id=-'.$owner_id.'&album_id='.$album_id.'&rev='.$rev.'&extended='.$extended.'&feed_type='.$feed_type.'&count='.$count.'&v=5.73');
    $result = json_decode($query, true); // Декодируем полученный json массив
    
    //echo $query;
    $response = $result['response'];
    $output = '';
    $pdo = $modx->getService('pdoTools');
    
    foreach ($response as $res) {    
        $res['class'] = $class;
        $output .= $pdo->getChunk($tpl, $res);
    }
    return $output;
Дмитрий
21 февраля 2018, 14:39
modx.pro
1 924
0

Inherit Template

Есть плагин Inherit Template
Его код.
В TV выбирается шаблон. Когда создаётся дочерний ресурс, то у него устанавливается выбранный в TV у родителя шаблон. Как сделать, чтобы у нового (дочернего) в TV устанавливался шаблон родителя? А может даже пустой, если в параметр плагина установить.
Также при быстром создании не работает плагин. Если с этим, что-то можно сделать дополнительно, то это будет хорошо.
Кто хорошо разбирается можете подправить? Спасибо.
<?php
/**
 * Inherit Template for MODx Revolution
 *
 * This plugin sets the new document template to have a default template from
 * parent's TV selection. This is only triggered by 'OnDocFormRender' event.
 * This only works one level, as it's intended.
 *
 * Inherit Template is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * Inherit Template is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * Inherit Template; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * @author      goldsky     <goldsky.milis@gmail.com>
 * @copyright   Copyright (c) 2012, goldsky
 * @license     GPL v2
 *
 * @package     Inherit Template
 * @subpackage  plugin
 */
// this plugin only apply to the new document
if (empty($scriptProperties['mode']) || $scriptProperties['mode'] !== 'new') {
    return;
}
if ($modx->event->name === 'OnDocFormRender') {
    // get the parent's ID
    $parentObj = $modx->getObject('modResource', $_REQUEST['parent']);
    if (!$parentObj) {
        return;
    }
    $parent = $parentObj->toArray();

    // checking the parent's TV
    $inheritTplObj = $modx->getObject('modTemplateVar', array(
        'name' => $modx->getOption('inheritTpl.tvname')
            ));

    if (!$inheritTplObj || !$inheritTplObj->hasTemplate($parent['template'])) {
        return;
    }

    // get the value from the parent's TV
    $inheritTpl = $inheritTplObj->toArray();
    $tvValueObj = $modx->getObject('modTemplateVarResource', array(
        'tmplvarid' => $inheritTpl['id'],
        'contentid' => $parent['id']
            ));
    if (!$tvValueObj) {
        return;
    }
    $tvValueArray = $tvValueObj->toArray();

    // force/override the template to the opening document
    $modx->controller->setProperty('template', $tvValueArray['value']);

    return;
}
return;
Дмитрий
08 февраля 2018, 18:06
modx.pro
1 530
0

Цикл вывода

Имеется чанк.
<div class="row row-flow">
    [[!If?
        &subject=`[[+pic-url-1]]`
        &operator=`notempty`
        &then=`[[!$GroupPicItemTpl? &pic_url=`[[+pic-url-1]]`]]`
    ]]
</div>
И GroupPicItemTpl
<div class="col [[!If? &subject=`[[+s]]` &operator=`notempty` &then=`s[[+s]]` &else=`s12`]] [[!If? &subject=`[[+m]]` &operator=`notempty` &then=`m[[+m]]` &else=`m6`]] [[!If? &subject=`[[+l]]` &operator=`notempty` &then=`l[[+l]]` &else=`l3`]]">
    <div class="card">
        <div class="card-image">
            <img class="materialboxed" data-external="[[+pic_url]]" src="[[!pthumb? &input=`[[+pic_url]]` &options=`w=500&h=300&zc=1`]]" />
        </div>
    </div>
</div>
Как мне всего 15 раз это провернуть. Где pic-url-# число, меняется от 1 до 15. Я так полагаю это только через сниппет можно сделать? Подскажите код. Спасибо
Дмитрий
06 февраля 2018, 09:47
modx.pro
2 035
0

Не отрабатывает pthumb

Есть код в чанке
<div class="row row-flow">
    [[!If?
        &subject=`[[+url1]]`
        &operator=`notempty`
        &then=`
        <div class="col [[!If? &subject=`[[+s]]` &operator=`notempty` &then=`s[[+s]]` &else=`s12`]] [[!If? &subject=`[[+m]]` &operator=`notempty` &then=`m[[+m]]` &else=`m6`]] [[!If? &subject=`[[+l]]` &operator=`notempty` &then=`l[[+m]]` &else=`l3`]]">
            <div class="card">
                <div class="card-image">
                    <img class="materialboxed" data-external="[[+url1]]" src="[[!pthumb? &input=`[[+url1]]` &options=`w=500&h=300&zc=1`]]" />
                </div>
            </div>
        </div>
        `
    ]]
</div>
Так вот содержимое thenвообще не выводится. Я пробовал по разному. Если поставить также вне [[+url1]], то всё отрабатывается.
Если убрать &options=`w=500&h=300&zc=1` из pthumb, то код выводится с необрезанной картинкой соответственно. Как заставить работать этот код?
Дмитрий
01 февраля 2018, 10:51
modx.pro
552
-1

Нужна пагинация кастомного сниппета

Ребята, нужна пагинация сниппета, чтобы с pdoPage работало. Помогите.
<?php
// VK API
    $owner_id = $modx->getOption('owner_id', $scriptProperties, '0'); // Группа
    $album_id = $modx->getOption('album_id', $scriptProperties, '0'); // Альбом
    $rev = $modx->getOption('rev', $scriptProperties, '1'); // 1 новые сверху
    $extended = $modx->getOption('extended', $scriptProperties, '0'); // Расширенные поля
    $feed_type = $modx->getOption('feed_type', $scriptProperties, 'photo'); // photo, photo_tag
    $count = $modx->getOption('count', $scriptProperties, ''); // Количество загружаемых фото
    $class = $modx->getOption('class', $scriptProperties, '');
    $tpl = $modx->getOption('tpl', $scriptProperties, '@INLINE <li><img src="[[+src_bigxx]]"></li>');
    
    $query = file_get_contents('https://api.vk.com/method/photos.get?owner_id=-'.$owner_id.'&album_id='.$album_id.'&rev='.$rev.'&extended='.$extended.'&feed_type='.$feed_type.'&count='.$count);
    $result = json_decode($query, true); // Декодируем полученный json массив
    
    $response = $result['response'];
    $output = '';
    $pdo = $modx->getService('pdoTools');
    
    foreach ($response as $res) {    
        $res['class'] = $class;
        $output .= $pdo->getChunk($tpl, $res);
    }
    return $output;
Дмитрий
30 января 2018, 17:36
modx.pro
1 329
0