Skip to content

Instantly share code, notes, and snippets.

@modx-developer
modx-developer / modx-tv-img-firstImageTV.php
Created December 8, 2016 01:52 — forked from govza/modx-tv-img-firstImageTV.php
Get first Image from modx content and add to firstImageTV
<?php
//OnDocFormSave
$img_path = $modx->getOption('imagesPath',$scriptProperties, MODX_ASSETS_URL."static/images/");
$imgName = $modx->getOption('ImageName',$scriptProperties,'default.png');
$TvValue = $modx->getOption('TV',$scriptProperties,'firstImage');
$def_img = $img_path.$imgName;
$img = $resource->GetTVValue($TvValue);
$text = $resource->content;
if(empty($img)) {
@modx-developer
modx-developer / SCSS_справочник
Created September 12, 2022 03:13 — forked from johnSmith8338/SCSS_справочник
Краткий справочник по SCSS
/*Краткий справочник по SCSS*/
/* 1. ---------------------------------------------------------------------------
Sass позволяет вкладывать правила CSS друг в друга.
Вложенные правила применяются только для элементов, соответствующих внешним селекторам.*/
#main p {
color: #00ff00;
width: 97%;
@modx-developer
modx-developer / style.css
Created September 12, 2022 03:15 — forked from kochevnik-web/style.css
CSS: Шпаргалка по свойствам Flex
flex-wrap: nowrap;
/* |---------------------------|
|#### #### #### #### #### #### ####
|#### #### #### #### #### #### ####
|#### #### #### #### #### #### ####
|---------------------------|
*/
flex-wrap: wrap;
@modx-developer
modx-developer / settimeout.js
Created November 19, 2022 12:51 — forked from Sentinel-7/settimeout.js
Отложенная загрузка метрики и скриптов
var loadedMetrica = false;
window.addEventListener('scroll', loadMetrica);
window.addEventListener('click', loadMetrica);
window.addEventListener('mousemove', loadMetrica);
function loadMetrica() {
if (!loadedMetrica) {
setTimeout(function() {
/* ТУТ ВАШ КОД И СКРИПТЫ, метрика например*/
},500);
}
<picture>
<source type="image/webp" media="(min-width: 1921px)" srcset="src/images/very-large/bike.webp">
<source type="image/png" media="(min-width: 1921px)" srcset="src/images/very-large/bike.png">
<source type="image/webp" media="(min-width: 1281px) and (max-width: 1920px)" srcset="src/images/regular/bike-regular.webp">
<source type="image/png" media="(min-width: 1281px) and (max-width: 1920px)" srcset="src/images/regular/bike-regular.png">
<source type="image/webp"
media="(min-width: 461px) and (max-width: 1280px) and (orientation: landscape)"
srcset="src/images/tablet-landscape/bike-tablet-landscape.webp">
@modx-developer
modx-developer / getYoutubeThumb.html
Created December 1, 2022 14:53 — forked from bartholomej/getYoutubeThumb.html
MODx: How to grab, cache and crop YouTube thumbnails
<a href="http://youtu.be/[[getPlaceholder? &id=`[[+parent]]` &placeholder=`tv.video`]]" target="_blank">
<img src="[[!pthumb? &input=`http://img.youtube.com/vi/[[getPlaceholder? &id=`[[+parent]]` &placeholder=`tv.video`]]/0.jpg` &options=`&w=480&h=270&zc=1`]]">
</a>
@modx-developer
modx-developer / modx-youtube-api
Created December 1, 2022 14:54 — forked from dubrod/modx-youtube-api
Pass a you Video ID or comma separated string of IDS to output a thumbnail and title and a link
//chunk youtube-video-tpl
<div class="col-1-3">
<a class="mediabox" rel="ytv" href="http://www.youtube.com/embed/[[+id]]">
<img src="[[+thumb]]" alt="">
<h3>[[+title]]</h3>
</a>
</div>
//Snippet
<?php
@modx-developer
modx-developer / lastModified.snippet.php
Created December 5, 2022 21:36 — forked from daemondevin/lastModified.snippet.php
A MODx snippet for dealing with browser caching. For example, say you have a stylesheet and you want to make sure everyone has the most recent version.
<?php
/**
* lastModified
*
* Copyright 2016 by demon.devin <demon.devin@gmail.com>
* Created on 10-07-2016
*
* lastModified is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
@modx-developer
modx-developer / modx-snippets.php
Created December 8, 2022 14:25 — forked from christianhanvey/modx-snippets.php
Useful snippets for MODX Revo
Snippet: [[SnippetName]]
Chunk: [[$ChunkName]]
System Setting: [[++SettingName]]
TV: [[*fieldName/TvName]]
Link tag: [[~PageId? &paramName=`value`]]
Placeholder: [[+PlaceholderName]]
<?php
@modx-developer
modx-developer / revo_helper.php
Created January 31, 2023 00:05 — forked from geforester/revo_helper.php
snippets for Fenom MODX
// Получение любого поля ресурса произвольного ресурса
{1 | resource : 'pagetitle'}
// Текущий год
{'' | date : 'Y'}
//Условие IF
{$id == '1' ? '' : $url}
//Получение изображения через переменную с точкой ($_pls)