Skip to content

Instantly share code, notes, and snippets.

@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', '');
<?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 / Call
Created November 7, 2018 12:30
Валюта с ЦБ РФ MODx
<center>
Курс USD: [[!getCurRate?&cur_output=`rubinusd`]]<br>
Курс EUR: [[!getCurRate?&cur_output=`rubineur`]]
</center>
@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 / 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 / Удаление старых версий пакетов MODx
Created November 10, 2018 01:03
Удаление старых версий пакетов MODx
<?php
define('MODX_API_MODE', true);
require 'index.php';
$modx->getService('error', 'error.modError');
$modx->setLogLevel(modX::LOG_LEVEL_ERROR);
$modx->setLogTarget('ECHO');
if (!XPDO_CLI_MODE) {
echo '<pre>';
}
$c = $modx->newQuery('transport.modTransportPackage');
<script language="JavaScript">
var login = 'netyspama';
var server = 'mail.ru';
var email = login+'@'+server;
var url = 'mailto:'+email;
document.write('<a href="'+url+'">'+email+'</a>');
</script>
@ru2fac
ru2fac / MinifyX using in MODx Revo
Last active November 12, 2018 20:21
MinifyX using in MODx Revo
<!--MinifyX call into HEAD and input all scripts and css in the necessary order, otherwise it may not work -->
[[MinifyX?
&minifyCss=`1`
&minifyJs=`1`
&registerJs=`default`
&registerCss=`default`
&jsSources=`
/assets/plugins/jquery/jquery-2.1.4.min.js,
/assets/js/scripts.js,
`
@ru2fac
ru2fac / Universal Email Template for AjaxForm MODx
Last active November 12, 2018 20:22
Universal Email Template for AjaxForm MODx
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<!--[if gte mso 9]>
<xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
<o:PixelsPerInch>96</o:PixelsPerInch>
</o:OfficeDocumentSettings>
</xml>
<![endif]-->
@ru2fac
ru2fac / 301 redirect from WWW to without WW
Created November 13, 2018 13:43
301 redirect from WWW to without WWW
# Insert this code to .htaccess file
RewriteEngine on
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain\.ru$ [NC]
RewriteRule ^(.*)$ https://domain.ru/$1 [R=301,L]