Skip to content

Instantly share code, notes, and snippets.

<?php
if ($modx->event->name == 'OnWebPagePrerender') {
$_url = parse_url($_SERVER['REQUEST_URI']);
if($modx->resource->isfolder && !preg_match("/\/$/", $_url['path'])) {
$id = $modx->resource->id;
$url = isset($_url['query']) ? $modx->makeUrl($id, '', $_url['query']) : $modx->makeUrl($id);
$modx->sendRedirect($url, ['responseCode' => 'HTTP/1.1 301 Moved Permanently']);
}
}
<?php
class FastResource
{
protected $fields = array();
protected $tvs = array();
protected $tvIds = array();
protected $tvtpl = array();
protected $tvDefaults = array();
protected $modx = null;
public $newDoc = true;
<?php
/**
* parseTemplate
*
* to parse chunks with DLTemplate
*
* @category snippet
* @version 1.0.0
* @author Pathologic (https://github.com/pathologic)
*/
@Pathologic
Pathologic / plugin.js
Created July 10, 2018 15:42
update of tinymce modxlink plugin
/**
* modxlink.js
*
* Based on link.js but with resource search added.
*
* By default both pagetitle and alias are searched.
*
* Author: markwillis82
* Date: 7/7/15
* update 64j 8/11/17
//<?php
/**
* SG2TV
*
* saves first or last image from SimpleGallery to TV
*
* @category plugin
* @version 1.0.0
* @internal @properties &tvName=TV name;text; &templates=Templates;text; &position=Image to save;list;first,last;first
* @internal @events OnDocFormSave
@Pathologic
Pathologic / GroupByLetter.php
Created December 14, 2017 19:17
Группировка документов по букве
<?php
/* Пример вызова:
[!GroupByLetter?
&parents=`24`
&depth=`3`
&showParent=`0`
&tpl=`@CODE:<a href="[+url+]">[+pagetitle+]</a><br>`
&wrapTpl=`@CODE:<h1>[+letter+]</h1>[+wrap+]`
&ownerTPL=`@CODE:[+dl.wrap+]`
!]
@Pathologic
Pathologic / convert.php
Created December 2, 2017 07:14
MaxiGallery to Simple Gallery converter
<?php
define('MODX_API_MODE', true);
include_once("index.php");
$modx->db->connect();
if (empty ($modx->config)) {
$modx->getSettings();
}
include_once(MODX_BASE_PATH.'assets/plugins/simplegallery/lib/table.class.php');
$modx->invokeEvent("OnManagerPageInit");
$q = $modx->db->query("SELECT * FROM {$modx->getFullTableName('maxigallery')} ORDER BY `gal_id` ASC, `pos` ASC, `id` ASC");
<?php
/**
* Class DLpaginate
*/
class DLpaginate
{
/**
* Script Name: *Digg Style Paginator Class
* Script URI: http://www.mis-algoritmos.com/2007/05/27/digg-style-pagination-class/
<?php
/* filter by TV of date format */
/* &filters=`tvdate:mytv:=:2017-09-28` */
include_once ('tv.filter.php');
/**
* Created by PhpStorm.
* User: Pathologic
* Date: 28.09.17
* Time: 13:09
*/
@Pathologic
Pathologic / Calendar.php
Last active August 28, 2017 00:33
php calendar
<?php
/**
* Class Calendar
*/
abstract class Calendar
{
protected $month = 0;
protected $year = 0;
protected $dates = array();