Skip to content

Instantly share code, notes, and snippets.

@tim-bec
tim-bec / gist:5708535
Created June 4, 2013 19:01
RegEx Key and replacement for redmine + sourcetree issue link
Regex Pattern:
(\#)+((?:[0-9]*)?)
Replace With:
<a href="https://redmine.company.com/issues/$2">$1$2</a>
@tim-bec
tim-bec / gist:5711512
Last active September 8, 2017 10:13
Referenzierte Werte aus einer MetaModel Tabelle holen (z.b. Herstellernamen aus einem zweiten MetaModel)
<?php
#Vorbereiten
$producer = MetaModelFactory::byTableName('mm_producer')->findById($arrItem['raw']['producer']);
# Die spalte 'name' aus dem array $producer ausgeben
echo $producer->get('name');
@tim-bec
tim-bec / gist:5711780
Last active December 18, 2015 02:29
Referenziertes MetaModel laden und daraus einen Translatedtext (introduction) abrufen, kürzen, abschneiden und ausgeben.
<?php
#Vorbereiten
$longtext = MetaModelFactory::byTableName('mm_projects')->findById($arrItem['raw']['project']['id'])->get('introduction');
# Longtext an string übergeben
$string = $longtext['value'];
$string = (strlen($string) > 123) ? substr($string,0,120).'...' : $string;
echo $string;
?>
@tim-bec
tim-bec / gist:5711988
Created June 5, 2013 06:28
Metadescription und pageTitel für contao in templates überschreiben
<?php
#strings bereinigen
$metadescription = strip_tags($desc);
$title = strip_tags($title);
$GLOBALS['objPage']->description = $metadescription;
$GLOBALS['objPage']->pageTitle.= ' ' . $title;
?>
@tim-bec
tim-bec / gist:5800551
Created June 17, 2013 21:17
Contao TinyMCE very reduced
<?php if (!defined('TL_ROOT')) die('You cannot access this file directly!');
/**
* Contao Open Source CMS
* Copyright (C) 2005-2013 Leo Feyer
*
* Formerly known as TYPOlight Open Source CMS.
*
* This program is free software: you can redistribute it and/or
@tim-bec
tim-bec / gist:5800557
Created June 17, 2013 21:18
TinyMCE in Contao austauschen (dcaconfig)
<?php
// Die eigene RTE-Konfiguration verwenden für
//Artikel-Teaser
$GLOBALS['TL_DCA']['tl_article']['fields']['teaser']['eval']['rte'] = 'tinyCustom';
// Events-Details
$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['details']['eval']['rte'] = 'tinyCustom';
// Kommentare
$GLOBALS['TL_DCA']['tl_comments']['fields']['comment']['eval']['rte'] = 'tinyCustom';
// Text-Elemente
$GLOBALS['TL_DCA']['tl_content']['fields']['text']['eval']['rte'] = 'tinyCustom';
@tim-bec
tim-bec / gist:6399626
Last active December 22, 2015 01:58
Contao Image-Prozessing for responsive images
<?php
$this->import('Environment');
$ua = $this->Environment->agent; // Import User Agent class
// check if agent is mobile
if($ua->mobile) {
$image_link = $arrItem['raw']['picture']; // load picture url
$image = $this->getImage($image_link,1024,768,'proportional'); // create thumb $link, $w,$h,$cropmode
}
@tim-bec
tim-bec / contao-colorbox.html5
Last active December 26, 2015 03:09
Contao Colorbox width&height by andreasisaak
<?php
// Add the colorbox style sheet
$GLOBALS['TL_CSS'][] = 'assets/jquery/colorbox/'. COLORBOX .'/css/colorbox.min.css||static';
?>
<script src="<?php echo TL_ASSETS_URL; ?>assets/jquery/colorbox/<?php echo COLORBOX; ?>/js/colorbox.min.js"></script>
<script>
(function($) {
@tim-bec
tim-bec / gist:7249043
Last active December 27, 2015 01:59
Contao: Include Modul Filter in regular navigation
<?php
// Include CEs or Modules into the navigation list.
$arrPageFilters = array(
// Page-ID => FilterModule-ID / or FilterContent-ID
23 => 33
);
?>
@tim-bec
tim-bec / gist:7339567
Created November 6, 2013 16:44
Change some classes while scrolling
$(function() {
$(window).scroll(function() {
var scrolled = $(window).scrollTop();
if (scrolled > 20) {
$('header').addClass('topFixed');
}
if (scrolled > 50) {
$('header').addClass('small');