Skip to content

Instantly share code, notes, and snippets.

View Rachind's full-sized avatar

rachind Rachind

  • Webservice
  • Saint-Petersburg, Russia
View GitHub Profile
@Rachind
Rachind / modx-snippet-bootstrap-row-clearfix.php
Created September 19, 2016 07:02
MODX Bootsrap row clearfix snippet
<?php
//[[clearfix? &idx=`[[+idx]]` &tpl=`<div class="clearfix visible-sm-block"></div>` &n=`2`]]
if(($idx % $n) == 0) echo $tpl;
@Rachind
Rachind / modx-api-create-alias.php
Created September 13, 2016 21:35
MODX API create alias
<?
$new_res = $modx->newObject('modResource', $resource_data);
$alias = $new_res->cleanAlias($title);
@Rachind
Rachind / modx-clear-cache.php
Created September 13, 2016 21:33
MODX Clear Cache
<?php
// Dan Gibbs
// Clear MODx Revolution Cache (2.1 and later)
// Path to MODx Core Directory
define("MODX_CORE_PATH", "../core/");
define("MODX_CONFIG_KEY", "config");
// Include MODx main class
include(MODX_CORE_PATH . "model/modx/modx.class.php");
@Rachind
Rachind / modx-base-setup.txt
Last active January 16, 2024 07:38
MODX Base Setup
Приложения:
TinyMCE Rich Text Editor
Ace
FormIt
pdoTools
translit
filetranslit
pthumb
FetchIt
MIGX
@Rachind
Rachind / modx-babel-switch-context.php
Created August 9, 2016 09:43
MODX Babel Switch Context
<?php
// Работаем только на фронтенде и только с friendly urls
if ($modx->event->name != 'OnHandleRequest' || $modx->context->key == 'mgr' || !$modx->getOption('friendly_urls')) {return;}
// Получаем запрашиваемый url
$alias = $modx->getOption('request_param_alias', null, 'alias', true);
$request = &$_REQUEST[$alias];
// Выбираем контексты с настройкой base_url
$q = $modx->newQuery('modContextSetting', array('key' => 'base_url', 'value:!=' => ''));
@Rachind
Rachind / modx-babel-settings.txt
Last active October 14, 2019 06:13
MODX Babel Settings
_____________________________________________________________
1. Настройки контекстов
--- Контекст: web ---
Общая информация:
Ключ: web
Имя: Русский
Описание: Русский
Настройки контекста:
@Rachind
Rachind / jquery-scroll-menu.js
Last active January 11, 2021 12:35
Jquery Scroll Menu
$(function(){
$(".scroll").on('click', function(e) {
e.preventDefault();
//calculate destination place
var dest = 0;
if ($(this.hash).offset().top > $(document).height() - $(window).height()) {
dest = $(document).height() - $(window).height();
} else {
dest = $(this.hash).offset().top;
}
@Rachind
Rachind / AddingDynamically.jquery.masonry.js
Created July 15, 2016 06:45
Dynamically Adding HTML Elements to a Masonry Container
var mediaItemContainer = $( '#container' );
mediaItemContainer.masonry( {
columnWidth: '210px',
itemSelector: '.item'
} );
$( mediaItemContainer ).prepend( '<div class="item">foo</div>' );
$( mediaItemContainer ).masonry( 'reloadItems' );
$( mediaItemContainer ).masonry( 'layout' );
@Rachind
Rachind / jquery.show-more.js
Last active December 9, 2016 06:20
Jquery show more
jQuery.fn.extend({
hideOther: function(num){
var elem = $(this);
$(elem).wrapAll('<div class="other-all-outer"></div>').attr('data-num', 2).after('<div class="more-btn btn btn-transparent">Загрузить еще</div>').children('.item').slice(num).wrapAll('<div class="other-all"></div>').parent().hide();
$(this).closest('.other-all-outer').find('.more-btn').on('click', function(e){
e.preventDefault();
var offset_num = parseInt($(elem).data('num')),
count = num * offset_num;
$(this).closest('.other-all-outer').find('.other-all').children('.item').unwrap();
offset_num++;
@Rachind
Rachind / snippet-resourceList.php
Last active July 15, 2016 07:07
Snippet resourcesList
<?php
// сниппет resourcesList
// можно формировать по parent и по template
// в возможных значениях tv: @EVAL return $modx->runSnippet('resourcesList', array('template'=>17));
$q = $modx->newQuery('modResource');
$q->select(array(
'modResource.id as id',