Skip to content

Instantly share code, notes, and snippets.

View sashabeep's full-sized avatar

Sasha Beep sashabeep

View GitHub Profile
@sashabeep
sashabeep / evo3controllersdumb.md
Last active October 26, 2022 13:35
Как подключить контроллеры втупую в Evolution 3.0

1. Создать свой пакет

Это рекомендуемый подход. В большинстве случаев вы создадите всего 1 пакет. Выполняем в папке /core

php artisan package:create main

Введите имя своего пакета - Main

@sashabeep
sashabeep / commerce-growl.js
Created January 12, 2021 14:47
Toastify growl for Evolution CMS Commerce
//using https://github.com/apvarun/toastify-js
$(document).on('cart-add-complete.commerce', function (e, params) {
var instance = params.data.instance;
switch(instance){
case 'comparison':
var growlText = "Товар добавлен к сравнению";
var growlLink = "/compare";
break;
case 'wishlist':
var growlText = "Товар добавлен в избранное";
@sashabeep
sashabeep / field_color.tpl
Created November 30, 2020 11:19
Pagebuilder field type color
<div class="field type-<?= $field['type'] ?>" data-field="<?= $name ?>">
<?php if (!empty($field['caption'])): ?>
<div class="field-name"><?= $field['caption'] ?></div>
<?php endif; ?>
<input type="text" <?php if($value){ echo('style="background-color:'.$value.'"'); } ?> name="contentblocks_<?= $name ?>" value="<?= htmlentities($value) ?>" oninput="this.setAttribute('value', this.value)" onfocus="this.setAttribute('type', 'color')" onblur="this.setAttribute('type', 'text'); this.style.backgroundColor=this.value">
<?php if (!empty($field['note'])): ?>
<div class="field-note"><?= $field['note'] ?></div>
<?php endif; ?>
@sashabeep
sashabeep / findinset.php
Created October 9, 2020 07:58
Find in set snippet for Evolution CMS
<?php
$id = $modx->documentObject['id'];
$res = $modx->db->select("contentid", $modx->getFullTableName('site_tmplvar_contentvalues'), "FIND_IN_SET('".$id."',value) AND tmplvarid=9");
$arr = $modx->db->makeArray($res);
$final = Array();
foreach($arr as $k=>$v){
$final[]=($v['contentid']);
}
return(implode(",",$final));
@sashabeep
sashabeep / formDataWithFiles.jquery.js
Created July 24, 2020 14:56
Send form via ajax with attachments
$(document).on('submit', 'form.myFormWithFiles', function (event) {
event.preventDefault();
event.stopImmediatePropagation();
var $this = $(this);
var formData = new FormData($($this)[0]);
$.ajax({
type: $this.attr('method'),
url: $this.attr('action'),
data: formData,
@sashabeep
sashabeep / sgimport-static.php
Last active April 19, 2024 13:13
Simple Gallery import from static folders
<?php
define('MODX_API_MODE', true);
define('MODX_BASE_PATH', __DIR__ . '/');
define('MODX_BASE_URL', '/');
define('MODX_SITE_URL', 'http://www.sitename.ru/');
include_once("index.php");
$modx->db->connect();
if (empty ($modx->config)) {
@sashabeep
sashabeep / gist:6779969d349f80ea4a23fa826850cdb4
Last active June 9, 2020 09:03
docLister latest news from subfolders
[[oneLatestResByParent]]
<?php
if (!function_exists('show_latest')) {
function show_latest() {
global $modx;
$output = '';
$table = $modx->getFullTableName('site_content');
$result = $modx->db->select('id, parent', $table, '(parent=61 OR parent=63 OR parent=64) AND deleted=0 AND published=1', 'pub_date ASC, createdon ASC', '');
$members = $modx->db->makeArray( $result );
$struct = [];
@sashabeep
sashabeep / amocrm.sender.php
Last active March 7, 2023 09:47
Отправка сделки на AmoCRM
<?php
//ПРЕДОПРЕДЕЛЯЕМЫЕ ПЕРЕМЕННЫЕ
$responsible_user_id = ######; //id ответственного по сделке, контакту, компании
$lead_name = 'Заявка с сайта'; //Название добавляемой сделки
$lead_status_id = ''; //id этапа продаж, куда помещать сделку. Пусто - неразобранное
$lead_desc = '' //Дополнительная заметка к сделке. Сюда можно поместить тело письма и т.д.
$contact_name = $cname; //Название добавляемого контакта
$contact_phone = $cphone; //Телефон контакта
@sashabeep
sashabeep / PaidDelivery.tpl
Created April 3, 2020 10:35
Commerce - Paid delivery when sum < N
$title = 'Доставка курьером';
$price = ci()->currency->convertToActive(100);
switch ($modx->Event->name) {
case 'OnRegisterDelivery': {
$params['rows']['fixed'] = [
'title' => $title,
'price' => $price,
];
$params['rows']['sam'] = [
@sashabeep
sashabeep / changetitleprice.plugin.inc.php
Last active June 26, 2024 07:43
MultiTV line as single cart item for Commerce
switch ($modx->event->name) {
case 'OnBeforeCartItemAdding': {
$offset = intval($params['item']['options']['variant'])-1;
$itemid = intval($params['item']['id']);
$myitemfields = json_decode($modx->runSnippet("multiTV",Array('tvName'=>'variant','toJson'=>1,'display'=>1,'offset'=>$offset,'docid'=>$itemid)),TRUE)[0];
$params['item']['price'] = $myitemfields['price'];
$params['item']['name'] = $myitemfields['title'];
}
}