mFilter2 - фильтрация по кнопке (выключить автофильтр)
05 августа 2017, 09:28
<script>
$(document).ready(function(){
$(document).off('change', '#mse2_filters');
$('#mse2_filters [type="submit"]').removeClass('hidden');
});
</script>или&filterOptions=`{"autoLoad":0}`Читать дальше
Вывод всех тегов ms2Gallery
07 июля 2017, 08:12
{'pdoResources' | snippet : [
'loadModels' => 'ms2gallery',
'class' => 'msResourceFileTag',
'leftJoin' => '{
"File":{ "class":"msResourceFile", "on":"File.id = msResourceFileTag.file_id" }
}',
'select' => '{
"msResourceFileTag": "*",
"File": "*"
}',
'where' => '{ "File.resource_id": ' ~ $_modx->resource.id ~ ' }',
'groupby' => 'tag',
'sortby' => '{ "tag":"ASC" }',
'limit' => 0,
'tpl' => '@INLINE <span>{$tag}</span>'
'outputSeparator' => ', '
]}Читать дальше
Проверка отправки почты в MODX
16 июня 2017, 15:55
Запустить код в дополнении Console:
Читать дальше
<?php
$to = 'site@mail.ru';
$theme = 'Site URL: ' . MODX_HTTP_HOST;
$body = 'Test mail message';
$from = $modx->getOption('emailsender');
$modx->getService('mail', 'mail.modPHPMailer');
$modx->mail->address('to', $to);
$modx->mail->set(modMail::MAIL_FROM, $from);
$modx->mail->set(modMail::MAIL_FROM_NAME, 'Console');
$modx->mail->set(modMail::MAIL_SUBJECT, $theme);
$modx->mail->set(modMail::MAIL_BODY, $body);
$modx->mail->setHTML(true);
if (!$modx->mail->send()) {
echo 'Sending failed. Error: ' . $modx->mail->mailer->ErrorInfo;
} else {
echo 'Success';
}
$modx->mail->reset();Читать дальше
Плавный скроллинг по клику на ссылку
16 июня 2017, 15:33
<a href="#" onclick="
$('body,html').animate({
scrollTop: $('.contacts').first().offset().top
}, 600);
return false;
">Обратная связь</a>Читать дальше
Список ресурсов для ТВ «Список с одиночным выбором»
17 апреля 2017, 17:52
@EVAL return $modx->runSnippet('pdoResources', array('parents' => 64, 'limit' => 0, 'tpl' => '@INLINE {$pagetitle}=={$id}', 'outputSeparator' => '||', 'where' => '{"parent":64}', 'sortby' => '{"menuindex":"ASC"}'));Читать дальше
Получение заголовка видео с youtube
08 апреля 2017, 10:24
Создаём плагин на событие OnDocFormSave
Читать дальше
<?php
if ($mode == 'new') {
if (strpos(trim($resource->pagetitle), ' ') === false) {
$url = 'https://www.youtube.com/watch?v=' . $resource->pagetitle;
$html = file_get_contents($url);
$dom = new DomDocument();
$dom->loadHTML('<?xml version="1.0" encoding="UTF-8"?>'. $html);
if ($title = $dom->getElementById('eow-title')) {
$modx->log(1, $resource->pagetitle);
$video_id = $resource->pagetitle;
$resource->set('pagetitle', $title->nodeValue);
$resource->set('template', 18);
$resource->setTVValue('video', $video_id);
$resource->save();
}
}
}Теперь, чтобы добавить видео на сайт, создаём новый ресурс, в заголовок которого вставляем ID видео с Youtube. Плагин вытащит название этого видео, а ID сохранит в соответствующем ТВ.Читать дальше
Cортировка по ТВ-параметру ЧИСЛО для pdoResources
12 января 2017, 10:11
[[pdoResources?
&tpl=`@INLINE {$pagetitle} - {$price}`
&sortby=`{"CAST(`TVprice`.`value` AS DECIMAL(13,3))":"ASC"}`
&includeTVs=`price`
]]Читать дальше
Запросы INSERT и UPDATE на PDO
06 декабря 2016, 08:10
// 'modx_table_name', array('row1' => 1, 'row2' =>2)
function _INSERT($table, $data){
$keys = array_keys($data);
$fields = '`' . implode('`,`', $keys) . '`';
$placeholders = substr(str_repeat('?,', count($keys)), 0, -1);
$sql = "INSERT INTO {$table} ({$fields}) VALUES ({$placeholders});";
$stmt = $this->modx->prepare($sql);
if (!$stmt->execute(array_values($data))) {
$this->modx->log(1, print_r($stmt->errorInfo(), true) . ' SQL: ' . $sql);
}
}
// 'modx_table_name', array('row1' => 1, 'row2' => 2), 'id', 1
function _UPDATE($table, $data, $key, $val){
if(!$key || !$val) return false;
$placeholders = array();
foreach(array_keys($data) as $k) $placeholders[] = "`{$k}` =?";
$placeholders = implode(', ', $placeholders);
$data = array_values($data);
array_push($data,$val);
$sql = "UPDATE {$table} SET {$placeholders} WHERE `{$key}` =?;";
$stmt = $this->modx->prepare($sql);
if (!$stmt->execute(array_values($data))) {
$this->modx->log(1, print_r($stmt->errorInfo(), true) . ' SQL: ' . $sql);
}
}Читать дальше
Подгрузка статей кнопкой с помощью pdoPage
19 сентября 2016, 10:27
<div class="news-items" id="newsItems">
[[!+news-nav]]
<div class="rows" style="overflow: hidden;">
[[!pdoPage?
&parents=`18`
&tpl=`newItemTpl`
&showHidden=`1`
&includeTVs=`image`
&limit=`4`
&sortby=`{"publishedon":"ASC"}`
&pageVarKey=`news-page`
&totalVar=`news-total`
&pageNavVar=`news-nav`
&pageCountVar=`news-count`
&ajaxMode=`button`
&ajaxElemWrapper=`#newsItems`
&ajaxElemRows=`#newsItems .rows`
&ajaxElemPagination=`#newsItems .pagination`
&ajaxElemLink=`#newsItems .pagination a`
&ajaxElemMore=`#newsItems .more`
&ajaxTplMore=`@INLINE <span class="news-more more"><span></span>Показать еще</span>`
]]
</div>
</div>Читать дальше
Разбивка страниц по категориям (родителям)
11 августа 2016, 22:24
<div id="pdopage">
<div class="rows">
[[!pdoPage?
&parents=`0`
&level=`0`
&limit=`6`
&where=`{"modResource.parent:!=":0}`
&sortby=`{"p_menuindex":"ASC", "publishedon":"DESC"}`
&ajaxMode=`default`
&leftJoin=`{
"Parent":{"class":"modResource", "on":"Parent.id = modResource.parent"}
}`
&select=`{
"modResource":"*",
"Parent":"Parent.id as pid, Parent.pagetitle as parent_pagetitle, Parent.uri as p_uri, Parent.menuindex as p_menuindex"
}`
&tpl=`@INLINE <h4 class="parent-title parent-{$pid}" data-pid="{$pid}">{$parent_pagetitle}</h4>
<p>{$pagetitle}</p>`
]]
</div>
[[!+page.nav]]
</div>
<script>
function hideTitles() {
$('.parent-title').hide();
$('.parent-title').each(function(){
$('.parent-' + $(this).data('pid')).first().show();
});
}
hideTitles()
$(document).on('pdopage_load', function(e, config, response) {
hideTitles()
});
</script>Читать дальше
RSS
Объектная