Skip to content

Instantly share code, notes, and snippets.

View sashabeep's full-sized avatar

Sasha Beep sashabeep

View GitHub Profile
@webber12
webber12 / Helper.php
Last active February 12, 2024 10:16
Helper example
<?php
namespace EvolutionCMS\Main;
//положить файл в папку core/custom/packages/Main/src/
//для использования в любом другом месте добавить use EvolutionCMS\Main\Helper;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
@sashabeep
sashabeep / test.php
Created February 15, 2023 16:33
Evo 2.0 api test
<?php
define('MODX_API_MODE', true);
define('MODX_BASE_PATH', __DIR__."/");
define('MODX_BASE_URL', '/');
define('MODX_SITE_URL', 'http://sitename.tld/');
include_once(MODX_BASE_PATH."index.php");
$modx->db->connect();
if (empty ($modx->config)) {
@webber12
webber12 / OrderWithProducts.php
Created November 14, 2022 17:48
Список заказов вместе с продуктами
protected function getOrderList()
{
$arr = [];
$currentUser = $this->data['user']['id'] ?? 0;
if(!empty($currentUser)) {
$arr = app('evouser')->do('OrderList', [ 'user' => $currentUser ]);
}
if(!empty($arr['data'])) {
//print_r($arr['data']);
<?php
define('MODX_API_MODE', true);
include_once("index.php");
$modx->db->connect();
if (empty ($modx->config)){
$modx->getSettings();
}
switch($_REQUEST['q']){
case 'award_form':
$result = $modx->runSnippet('FormLister', array(
<?php
define('MODX_API_MODE', true);
include_once("index.php");
$modx->db->connect();
if (empty ($modx->config)){
$modx->getSettings();
}
$modx->invokeEvent("OnWebPageInit");
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')){
@0test
0test / FL and JS
Last active September 17, 2021 10:06
ajax Formlister
<div id="myform_wrapper">
{{fl_ajax_form}}
</div>
<script>
$(document).ready(function(){
$(document).on('submit', '#myform',function(e){
var form = $('#myform')[0];
var data = new FormData(form);
$.ajax({
type: 'post',
@antlionguard
antlionguard / twitter-remove-retweets.js
Last active July 23, 2024 17:10
With this script, you can remove all retweets you are retweeted on Twitter.
const timer = ms => new Promise(res => setTimeout(res, ms));
// Unretweet normally
const unretweetTweet = async (tweet) => {
await tweet.querySelector('[data-testid="unretweet"]').click();
await timer(250);
await document.querySelector('[data-testid="unretweetConfirm"]').click();
console.log('****// Unretweeted Successfully //****')
}
<?php
date_default_timezone_set('Europe/Moscow');
$host ='http://ursite.ru/manager/';
$auth_fields = [
'username' => 'administrator',
'password' => '******',
];
$header = [
'Accept: */*',
'Accept-Encoding: gzip, deflate',
switch ($modx->event->name) {
case 'OnManagerBeforeOrdersListRender': {
// добавляем столбец в таблицу заказов
$params['columns']['name'] = [
'title' => 'Имя',
'content' => function($data, $DL, $eDL) {
return !empty($data['fields']['fullname']) ? $data['fields']['fullname'] : '';
},
'sort' => 20,

#Laravel Routing, Request, Response, Validator

Ajax №5 или Laravel Routes для кастомных роутов и аякс запросов

Очень долгая история с вопросом как же правильно рабатать с Ajax в Evo вот методы которые предлагались ранеее:

В Evo 3.0 предлагаем поставить точку в выборе правильного решения через Laravel Routes