Skip to content

Instantly share code, notes, and snippets.

@OlegShchavelev
OlegShchavelev / index.tpl
Last active June 10, 2017 13:39
Модуль с этим товары покупают
{'!msProducts' | snippet : [
'parents' => '0',
'tpl' => 'lookedTpl.dtls',
'includeThumbs' => 'medium',
'link' => '1',
'master' => $_modx->resource.id
]}
@OlegShchavelev
OlegShchavelev / index.tpl
Created June 12, 2017 16:41
Изменения падежа при плейсхолдерах числительных
{'!count' | snippet: [
'parents' => $id ] | units : 'товар|товара|товаров'}
{'!AjaxForm' | snippet: [
'snippet' => 'FormIt',
'form' => 'tpl.AjaxForm.dtls',
'hooks' => 'FormItSaveForm, email',
'formFields' => 'name,phone,email1,message',
'fieldNames' => 'name==Имя отправителя,phone==Телефон,email1==Почта,message==Комментарии'
'validate' => 'name:required',
'emailSubject' => 'Заявка из раздела контакты',
'emailTo' => '[email protected]',
'emailTpl' => 'tpl.email.dtls',
@OlegShchavelev
OlegShchavelev / index.tpl
Last active July 21, 2017 15:17
Множественная проверка значений
// Если одно поле заполнено
{if $_modx->resource.pagetitle_section1 != '' || $_modx->resource.introtext_section1 != '' || $_modx->resource.image_section1}
{/if}
//Если все поля заполнены
{if $_modx->resource.pagetitle_section1 != '' && $_modx->resource.introtext_section1 != '' && $_modx->resource.image_section1}
{/if}
@OlegShchavelev
OlegShchavelev / main.tpl
Created August 8, 2017 12:11
Cчитаем количество ресурсов, в снипете pdoResources
{'!pdoResources' | snippet : [
'totalVar' => total_main
]}
$_modx->getPlaceholder('total_main')
@OlegShchavelev
OlegShchavelev / main.tpl
Created August 8, 2017 17:42
Migx Fenom
{set $rows = json_decode($_modx->resource.image_section3, true)}
<ul class="uk-grid uk-slideset">
{foreach $rows as $row}
<li><div class="tm-notifications-item"><img src="{$row.image}" alt="{$row.title}"></div></li>
{/foreach}
</ul>
@OlegShchavelev
OlegShchavelev / level.php
Created August 10, 2017 08:45
Уровень вложенности от id=1
<?php
$parentPageId = $modx->resource->get('id');
$level = count($modx->getParentIds($parentPageId));
echo $level;
@OlegShchavelev
OlegShchavelev / year.php
Created August 11, 2017 08:59
Сколько лет компании (автоматически)
<?php
$year = (date("Y"));
$bild = $year - $modx->getOption('year');
print $bild;
// Заводим в Client Config Year
@OlegShchavelev
OlegShchavelev / head.tpl
Created August 18, 2017 12:37
MODX SEO-теги v2
{if $_modx->resource.seotitle == ''}
<title>{$_modx->resource.pagetitle}{if $_modx->config.name_title == 1}{$_modx->config.separator_title}{$_modx->config.site_name}{/if}</title>
{else}
<title>{$_modx->resource.seotitle}{if $_modx->config.name_title == 1}{$_modx->config.separator_title}{$_modx->config.site_name}{/if}
</title>
{/if}
</title>
{if $_modx->resource.seokeywords != ''}<meta name="keywords" content="{$_modx->resource.seokeywords}">`{/if}
{if $_modx->resource.seodescription != ''}<meta name="description" content="{$_modx->resource.seodescription}">{/if}
{'!MinifyX' | snippet : [
'minifyCss' => 1
'minifyJs' => 1
'cssSources' => '
assets/ksytal/css/theme.css,
assets/ksytal/css/custom.css,
assets/ksytal/css/component.css
'
'jsSources' => '
assets/ksytal/js/jquery/jquery-1.11.3.min.js,