Skip to content

Instantly share code, notes, and snippets.

Avatar

Fritz Michael Gschwantner fritzmg

View GitHub Profile
@fritzmg
fritzmg / isotope_cart_ajax.js
Last active Aug 27, 2015
Contao Isotope cart AJAX actions
View isotope_cart_ajax.js
(function($)
{
// or use https://github.com/fczbkk/css-selector-generator instead
$.fn.getPath = function () {
if (this.length != 1) throw 'Requires one element.';
var path, node = this;
while (node.length) {
var realNode = node[0], name = realNode.localName;
if (!name) break;
@fritzmg
fritzmg / filetags.php
Created Jul 9, 2015
Replaces file paths like "files/lorem/ipsum/foo.jpg" in Contao text elements with {{file::…}} insert tags.
View filetags.php
<?php
/**
* Contao Open Source CMS
*
* Copyright (c) 2005-2015 Leo Feyer
*
* @license LGPL-3.0+
*/
@fritzmg
fritzmg / nav_switch.html5
Created Jul 13, 2015
Contao nav_default Template, which allows you to switch to the same subpage within a different "category". Simply create a new custom navigation module, select the pages that act as "category roots" and assign this template. You also need to use folder URLs and the page aliases must be the same (except for the first part, i.e. the "category").
View nav_switch.html5
<?php global $objPage; ?>
<ul class="<?= $this->level ?>" role="<?= ($this->level == 'level_1') ? 'menubar' : 'menu' ?>">
<?php foreach ($this->items as $item): ?>
<?php
// get the current page's alias and remove its first part
$arrAlias = explode('/', $objPage->alias);
array_shift($arrAlias);
@fritzmg
fritzmg / j_tablesort.html5
Created Nov 21, 2015
j_tablesort template which includes the default sort option provided by Contao
View j_tablesort.html5
<?php
// Add the tablesorter style sheet
$GLOBALS['TL_CSS'][] = 'assets/jquery/tablesorter/' . $GLOBALS['TL_ASSETS']['TABLESORTER'] . '/css/tablesorter.css|static';
?>
<script src="<?= TL_ASSETS_URL ?>assets/jquery/tablesorter/<?= $GLOBALS['TL_ASSETS']['TABLESORTER'] ?>/js/tablesorter.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.0.4/js.cookie.min.js"></script>
<script>
@fritzmg
fritzmg / nav_newscategories.html5
Created Nov 26, 2015
nav_newscategories template for the Contao news_categories extension which also takes the jumpTo page into account
View nav_newscategories.html5
<ul class="<?php echo $this->level; ?>">
<?php foreach ($this->items as $item): ?>
<?php
// build link to jumpTo page
if( $item['jumpTo'] )
{
$objJump = \PageModel::findByPk( $item['jumpTo'] );
if( $objJump !== null )
@fritzmg
fritzmg / www_klack_de.xml
Last active Dec 23, 2015
UPDATE: Use http://pastebin.com/dd45TDZY instead || MediaPortal WebEPG grabber file for klack.de
View www_klack_de.xml
<?xml version="1.0" encoding="utf-8"?>
<Grabber>
<Info language="de" availableDays="14" timezone="W. Europe Standard Time" version="2.1.0" />
<Channels>
<Channel id="13TH STREET Universal" siteId="112" />
<Channel id="3sat" siteId="1" />
<Channel id="Animal Planet" siteId="73" />
<Channel id="Animax" siteId="171" />
<Channel id="ANIXE HD" siteId="4" />
<Channel id="ARTE" siteId="6" />
@fritzmg
fritzmg / composer-switch-back.md
Created Mar 27, 2016
How to cleanly switch from composer back to the old ER2 in Contao
View composer-switch-back.md

How to cleanly switch from composer back to the old ER2 in Contao

The information given here in the German Contao Wiki can lead to problems. If you want to cleanly switch back to the old ER2 in Contao, you need to follow these steps. But before doing so, you should note down all the extensions that you still need after switching back and you should make sure that these extensions are available in the ER2 and still compatible with your Contao version.

  1. remove all modules and assets from installed extensions (see below)
  2. go to System » Settings » Inactive extensions, check [!composer] and uncheck [repository]
  3. reinstall all needed extensions via the extension repository
  4. once you are sure that everything is working as expected, you can delete the folder /composer and /system/modules/!composer
@fritzmg
fritzmg / be_rebuild_index.html5
Last active Aug 23, 2016
Contao RebuildIndex template with more feedback
View be_rebuild_index.html5
<div id="tl_maintenance_index" class="maintenance_<?= $this->isActive ? 'active' : 'inactive' ?>">
<h2 class="sub_headline_index"><?= $this->indexHeadline ?></h2>
<?php if ($this->indexMessage): ?>
<div class="tl_message">
<p class="tl_error"><?= $this->indexMessage ?></p>
</div>
<?php endif; ?>
@fritzmg
fritzmg / contao-event-pagination.md
Last active Jan 2, 2018
Previous and next events in the event_full template of Contao.
View contao-event-pagination.md

Contao Event Pagination

This event_full template creates a previous and next pagination for events. It uses the same HTML structure as the default pagination template. Of course you can change that to your needs. Simply download the event_full.html5 template and put it in your /templates directory.

Known limitations:

  • It ignores the start and end field.
  • It is limited to events from the same calendar. Otherwise the target URL might be wrong.
  • It will not work if the auto_item parameter is disabled.
@fritzmg
fritzmg / MySurcharge.php
Created Jan 15, 2019
Custom Contao Isotope Surcharge
View MySurcharge.php
<?php
use Isotope\Model\ProductCollection;
class MySurcharge
{
public function findSurchargesForCollection(ProductCollection $collection): array
{
return [\MySurchargeModel::build()];
}
You can’t perform that action at this time.