Skip to content

Instantly share code, notes, and snippets.

@zhabinka
zhabinka / vjikTwitter.php
Last active January 2, 2016 09:46
Сниппет для вывода ленты статусов из Twitter
<?php
/*
*
* vjikTwitter v0.2.1
* Сниппет для вывода ленты статусов из Twitter
*
* Автор: Предводителев Сергей
* Сайт: http://predvoditelev.ru/
* E-mail: sergey.predvoditelev@gmail.com
*
@zhabinka
zhabinka / getCheck.php
Last active January 2, 2016 14:46
Вывод документов с определённым значением TV.
<?php
$tvs = $modx->getCollection('modTemplateVarResource', array('tmplvarid' => 2, 'value' => 1));
if (count($tvs) > 4) return 'Найдено больше 4 документов';
foreach ($tvs as $tv) {
$res = $tv->getOne('Resource');
$output .= '<p><b>' .$res->get('pagetitle'). '.</b> ' .$res->get('introtext'). ' (' .$res->get('publishedon'). ')</p>';
}
return $output;
@zhabinka
zhabinka / modxmethod.php
Last active January 2, 2016 15:20
Методы MODx REVO
<?php
$modx->user // получение текущего пользователя
getOne();
getMany();
$modx->makeUrl($id);
@zhabinka
zhabinka / setTVValue.php
Created January 2, 2016 15:34
Изменение TV-параметров через сниппет.
<?php
if ($views = $modx->resource->getTVValue(3)) {
$views++;
} else {
$views = 1;
}
$modx->resource->setTVValue(3,$views);
return $views;
@zhabinka
zhabinka / getViews.php
Created January 2, 2016 15:47
Выводим общее количество просмотров всех страниц, созданных пользователем.
<?php
$user = $modx->user;
$resource = $user->getMany('CreatedResources');
foreach ($resource as $res) {
$views = $views + $res->getTVValue(3);
}
return $views;
@zhabinka
zhabinka / 0_reuse_code.js
Created January 18, 2017 18:46
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@zhabinka
zhabinka / arcticModal_head_include.html
Last active January 19, 2017 13:40
Всплывающее окно при первом и последующем посещении сайта.Установка времени жизни куки в минутах.
<head>
<!-- jQuery -->
<script src="//yandex.st/jquery/1.9.1/jquery.min.js"></script>
<!-- jQuery cookies
* https://github.com/carhartl/jquerycookie/blob/master/src/jquery.cookie.js
* http://codernote.ru/jquery/rabotascookiesnajquery/
-->
<script type="text/javascript" src="js/jquery.cookie.js"></script>
@zhabinka
zhabinka / text_to_comma.php
Last active January 19, 2017 14:50
Обрезать текст до запятой. https://modx.pro/help/10970/#comment-74490
/*
Code snippet
Вывод [[*tv:modifikator]]
*/
$text = $input;
$arr = explode(',',$text);
return $arr[1];
<?php
/*
pluginName DisableCache
Вешаем этот плагин на событие OnLoadWebDocument
*/
global $modx;
$modx->documentObject["cacheable"] = 0;
@zhabinka
zhabinka / config.inc.php
Created January 21, 2017 14:41
Замена стандартных файлов /core/config/config.inc.php
<?php
/*
define('MODX_CORE_PATH', 'c:/www/site.ru/core/');
define('MODX_CONFIG_KEY', 'config');
*/
$rootPath = $_SERVER['DOCUMENT_ROOT'];
if ($rootPath[strlen($rootPath) - 1] != '/') {
$rootPath = $rootPath . '/'; }