Skip to content

Instantly share code, notes, and snippets.

@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];
@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 / 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 / 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 / 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 / modxmethod.php
Last active January 2, 2016 15:20
Методы MODx REVO
<?php
$modx->user // получение текущего пользователя
getOne();
getMany();
$modx->makeUrl($id);
@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 / vjikTwitter.php
Last active January 2, 2016 09:46
Сниппет для вывода ленты статусов из Twitter
<?php
/*
*
* vjikTwitter v0.2.1
* Сниппет для вывода ленты статусов из Twitter
*
* Автор: Предводителев Сергей
* Сайт: http://predvoditelev.ru/
* E-mail: [email protected]
*