Skip to content

Instantly share code, notes, and snippets.

@eonarik
eonarik / finalParent.snippet.php
Created February 28, 2018 00:30
modx snippet finalParent
<?php
if (!isset($modx)) return '';
if (!function_exists('getParentIds'))
{
function getParentIds($id = 0, $depth = 9, $finalWhere = array('parent' => 0), $alias = 'modResource')
{
global $modx;
@eonarik
eonarik / robokassaLink.snippet.php
Last active August 7, 2018 10:31
modx snippet robokassaLink
@eonarik
eonarik / get2obj.js
Created September 27, 2018 17:29
js $_GET to javascript object
// рекурсивное преобразование урл параметров в js object
const get2obj = function () {
let obj = {}
let gets = location.search.substring(1).split('&')
for(var i = 0; i < gets.length; i++) {
let parts = gets[i].split('=')
let keys = decodeURIComponent(parts.shift()).replace(/\[(.*?)\]/g, '.$1').split(/\./)
obj = assignValue({...obj}, keys, parts.join('='), 0)
@eonarik
eonarik / functions.js
Last active December 20, 2018 19:32
js functions
const obj2get = function (obj) {
let data = []
for (let key in obj) {
let value = obj[key]
if (typeof value === 'object') {
assignValue(data, value, key)
} else {
data.push(`${key}=${value}`)
}
@eonarik
eonarik / turbo.html
Last active July 27, 2019 08:01
yandex turbo
requred pdoTools, phpthumbon, jevix
<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" xmlns:turbo="http://turbo.yandex.ru" version="2.0">
<channel>
<title>[[++site_name]]</title>
<link>[[++site_url]]</link>
<description>[[#[[++site_start]].description]]</description>
[[!pdoResources?
&parents=`0`
@eonarik
eonarik / getdata.class.php
Last active April 7, 2019 16:24
modx processor web/resources/getdata
<?php // v. 2.0.2
require_once dirname(dirname(dirname(__FILE__))).'/site/web/resources/getdata.class.php';
class modWebResourcesGetdataProcessor extends modSiteWebResourcesGetdataProcessor {
public function initialize(){
$this->setDefaultProperties(array(
'cache' => true, // Use cache
'cache_lifetime' => 3600, // cache seconds