Skip to content

Instantly share code, notes, and snippets.

@ru2fac
ru2fac / tagLister app
Created November 7, 2018 12:45
Tags in article MODx
<!-- create TV call "tags" with type "auto-tag" or similar from list of types and set to template.
Input tags into article through decimal(fo example article, blog, summer) and press SAVE.
Create template for search by tags and input code below:-->
[[!getResourcesTag?
&element=`pdoResources`
&elementClass=`modSnippet`
&grSnippet=`pdoPage`
&tpl=`postTpl`
&hideContainers=`1`
@ru2fac
ru2fac / copyrightYear
Created November 7, 2018 12:34
Copyright year MODx
<?php
$year = date("Y");
if($year == $start)
{ return $year;
} else {
return ''.$start.' – '.$year.'';
}
@ru2fac
ru2fac / Call
Created November 7, 2018 12:30
Валюта с ЦБ РФ MODx
<center>
Курс USD: [[!getCurRate?&cur_output=`rubinusd`]]<br>
Курс EUR: [[!getCurRate?&cur_output=`rubineur`]]
</center>
<?php
if (isset($options) && $options) {
$width = $height = $options;
}
if (!isset($bg) || !$bg) {
$bg = '#fff';
}
if (substr($input,0,1) == '/') $input = substr($input,1);
$path_info = pathinfo($input);
$cropedFile = 'assets/images/croped/'.$width.'/';
@ru2fac
ru2fac / Вариант 1
Last active November 6, 2018 00:39
Запретить Tickets заполнять introtext MODx
<?php
if ($modx->event->name == "OnDocFormSave") {
if ($resource->class_key != 'Ticket') return;
$introtext = $resource->get('introtext');
$generateIntrotext = $resource->getIntroText($resource->get('content'), false);
if (empty($resource->getProperty('disable_jevix'))) {
$generateIntrotext = $resource->Jevix($generateIntrotext);
}
if ($introtext == $generateIntrotext) {
$resource->set('introtext', '');
@ru2fac
ru2fac / Bootstrap
Created November 6, 2018 00:37
Сообщение об успешной отправке AjaxForm в модалке на Fancybox
<div class="modal fade" id="successModal" tabindex="-1" role="dialog" aria-labelledby="successModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="successModalLabel">Спасибо</h4>
</div>
<div class="modal-body">
</div>
[[pdoResources?
&parents=`0`
&select=`{
"modResource":"id, pagetitle",
"Children":"COUNT(Children.id) as count"
}`
&leftJoin=`{
"Children":{"class":"modResource", "on":"modResource.id = Children.parent"}
}`
&sortby=`{"id":"ASC"}`
<?php
switch ($modx->event->name) {
case 'OnWebPagePrerender':
$modx->resource->_output = str_replace('"index/', '"', $modx->resource->_output);
break;
case 'OnPageNotFound':
$uri = explode('?', $_SERVER['REQUEST_URI']);
if ($res = $modx->findResource('index' . $uri[0])) {
$modx->sendForward($res);
}
<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=`{
<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"}`