Skip to content

Instantly share code, notes, and snippets.

View Burick's full-sized avatar
🏠
Работаю из дома

Burick Burick

🏠
Работаю из дома
View GitHub Profile
@Burick
Burick / twog-modx.html
Created December 21, 2017 12:10 — forked from sepiariver/twog-modx.html
Twitter/OG Meta Tags for MODX
<!-- Open Graph Tags -->
<meta property="og:site_name" content="[[++site_name]]" />
<meta property="og:type" content="article" />
<meta property="og:title" content="[[*longtitle:default=`[[*pagetitle]]`]]" />
<meta property="og:description" content="[[*description:default=`[[++site_description]]`]]" />
<meta property="og:url" content="[[~[[*id]]? &scheme=`full`]]" />
<meta property="og:image" content="[[*image:default=`[[++site_image]]`]]" />
<meta property="fb:app_id" content="[[++fb_app_id]]" />
<meta property="article:publisher" content="[[++fb_url]]" />
<!-- Twitter Tags -->
@Burick
Burick / schema-head.tpl
Created December 21, 2017 12:10 — forked from sepiariver/schema-head.tpl
Schema.org head tags
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" itemscope itemtype="http://schema.org/{put something here}"> <!--<![endif]-->
<head>
<meta charset="[[++modx_charset]]">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>[[*pagetitle]] | [[++site_name]]</title>
<meta itemprop="name" content="[[++site_name]]">
@Burick
Burick / ContentBlocksTemplates.php
Created December 21, 2017 12:09 — forked from sepiariver/ContentBlocksTemplates.php
Scope ContentBlocks (modmore's premium plugin for MODX) to specific templates
<?php
$eventName = $modx->event->name;
switch($eventName) {
case 'OnDocFormPrerender':
if (!is_object($resource)) { // prevents bad error when user doesn't have perms to resource
$modx->log(modX::LOG_LEVEL_ERROR, '[ContentBlocks Templates] No Resource Object on line: ' . __LINE__);
return;
}
// a system setting must be created with the key 'contentblocks.enabled_template_ids'
$enabledTemplates = array_map('trim', explode(',', $modx->getOption('contentblocks.enabled_template_ids')));
@Burick
Burick / fontAwesomeInputOptions.php
Created December 21, 2017 12:09 — forked from sepiariver/fontAwesomeInputOptions.php
Font Awesome Input Options for MODX CMS
<?php
/*
* fontAwesomeInputOptions
* MODX Snippet
* @author YJ Tso @sepiariver
* GPL, no warranties, etc.
*
* Usage: execute in TV input options, preferably with @CHUNK binding
* alternatively install as Content Blocks input (link to repo coming soon)
*/
@Burick
Burick / prototype.snippet.php
Created December 21, 2017 12:09 — forked from sepiariver/prototype.snippet.php
Utility snippet for rapid prototyping in MODX CMS.
<?php
// Options
$limit = (int) $modx->getOption('limit', $scriptProperties, 3, true);
// $limit must be > 0
$limit = ($limit === 0) ? 1 : abs($limit);
$tpl = $modx->getOption('tpl', $scriptProperties, '');
if (empty($tpl)) return; // if empty what's the point?
$outputSeparator = $modx->getOption('outputSeparator', $scriptProperties, '');
$delim = $modx->getOption('delimiter', $scriptProperties, ',', true);
@Burick
Burick / getResourceImage.snippet.php
Created December 21, 2017 12:09 — forked from sepiariver/getResourceImage.snippet.php
Retrieves thumbnail paths from a json source in MODX.
<?php
// Options
$input = $modx->getOption('input', $scriptProperties, '');
if (empty($input)) return;
$size = $modx->getOption('size', $scriptProperties, 'original');
$toPlaceholder = $modx->getOption('toPlaceholder', $scriptProperties, '');
// Get stuff
$image = $modx->fromJSON($input);
if (!is_array($image)) return;
@Burick
Burick / TwitterX-modified
Created December 21, 2017 12:07 — forked from sepiariver/TwitterX-modified
Slight mods to TwitterX » http://www.qodo.co.uk/blog/twitterx-a-new-modx-extra-for-pulling-in-twitter-feeds-using-api-1.1/ Added cache_id property to use more than one snippet call on a page. Added toPlaceholder property to display output with custom placeholder. Added support for Twitter favorites timeline. Needs more testing.
/**
* TwitterX
*
* This package loads Twitter feeds using the new (and very annoying) Twitter
* 1.1 API. You will need to create a Twitter app and get the keys and tokens
* by creating a new app here: https://dev.twitter.com/apps/new
*
* This uses twitteroauth: https://github.com/abraham/twitteroauth
*
* TwitterX is free software; you can redistribute it and/or modify it
@Burick
Burick / cloneResource.php
Created December 21, 2017 12:06 — forked from sepiariver/cloneResource.php
A Snippet to clone a Resource into multiple, user-defined parent containers in arbitrary contexts
<?php
// get user-defined source document and target parents
$source = intval($modx->getOption('sourceId', $scriptProperties, ''));
$targets = array_map('trim', explode(',', $modx->getOption('targetIds', $scriptProperties, '')));
// to prevent accidents...
$_allowedUsers = explode(',', 'username1,username2');
// check stuff, and if passed then get the source document object
if ( !in_array($modx->user->get('username'), $_allowedUsers) || empty($source) || $source == 0 || !is_array($targets) || empty($targets) ) return;
$sourceDoc = $modx->getObject('modResource', $source);
<?php
/*
* Copyright (c) YJ Tso <[email protected]>
*
* GPL2, do what you want at your own risk. No warranties whatsoever.
*
*/
// Get &resources property from snippet call
$ids = array_map('trim', explode(',', $modx->getOption('resources', $scriptProperties, '')));
@Burick
Burick / customimgrenderer.js
Created December 21, 2017 12:06 — forked from sepiariver/customimgrenderer.js
Custom Collections Image Renderer
var myimagerenderer = function(value, metaData, record, rowIndex, colIndex, store) {
if (value != '' && value != null) {
var baseUrl = MODx.config.collections_renderer_basepath_img;
if (value.indexOf('http://') === 0) {
baseUrl = '';
}
return '<div class="myimagerenderer"><img src="' + baseUrl + value + '" width="100"></div>';
}
}