Skip to content

Instantly share code, notes, and snippets.

View fritzmg's full-sized avatar

Fritz Michael Gschwantner fritzmg

View GitHub Profile

Contao News Sync

Contao extension to automatically synchronize news entries between different installations.

Configuration

Install the extension on all Contao installations involved in the news synchronisation. After installation, you will see additional options in your Contao news archives under Synchronisation. In order to enable a news archive to be a source for the synchronisation, simply activate the Source for synchronisation option.

Then, on the target news archive, enable the Target for synchronisation option. You will then see additional options. Under Source URL fill in the URL to the Contao installation, from which you want to fetch news entries. Then save the news archive. After saving you will see the available news archives from the remote Contao installation under News archives. Enable the remote news archives from which you want to fetch news entries, then save again.

@fritzmg
fritzmg / git-context-global.reg
Created February 24, 2019 18:12
Windows scoop git global context menu
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Open Git Bash]
@="Open Git Bash"
"Icon"="C:\\ProgramData\\scoop\\apps\\git\\current\\git-bash.exe"
[HKEY_CLASSES_ROOT\*\shell\Open Git Bash\command]
@="\"C:\\ProgramData\\scoop\\apps\\git\\current\\git-bash.exe\" \"--cd=%1\""
; This will make it appear when you right click ON a folder
@fritzmg
fritzmg / MySurcharge.php
Created January 15, 2019 18:18
Custom Contao Isotope Surcharge
<?php
use Isotope\Model\ProductCollection;
class MySurcharge
{
public function findSurchargesForCollection(ProductCollection $collection): array
{
return [\MySurchargeModel::build()];
}
@fritzmg
fritzmg / contao-event-pagination.md
Last active January 2, 2018 10:27
Previous and next events in the event_full template of Contao.

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 / composer-switch-back.md
Created March 27, 2016 10:42
How to cleanly switch from composer back to the old ER2 in Contao

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 / contao-fineuploader-for-news.md
Last active August 16, 2019 11:27
Use fineuploader for news teaser images in Contao

Use fineuploader for news teaser images in Contao

Using these instructions you can replace the default file selector for news teaser images with a direct upload button. This upload button is implemented using the terminal42/contao-fineuploader extension.

First install the extension via the Composer package management for Contao (Packagist: terminal42/contao-fineuploader). Then insert the following content into contao/dca/tl_news.php:

$GLOBALS['TL_DCA']['tl_news']['fields']['singleSRC']['inputType'] = 'fineUploader';
$GLOBALS['TL_DCA']['tl_news']['fields']['singleSRC']['eval'] = [
 'storeFile' =&gt; true, 
@fritzmg
fritzmg / be_rebuild_index.html5
Last active August 23, 2016 11:32
Contao RebuildIndex template with more feedback
<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 / nav_newscategories.html5
Created November 26, 2015 14:26
nav_newscategories template for the Contao news_categories extension which also takes the jumpTo page into account
<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 / j_tablesort.html5
Created November 21, 2015 15:27
j_tablesort template which includes the default sort option provided by Contao
<?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 / isotope_cart_ajax.js
Last active August 27, 2015 15:39
Contao Isotope cart AJAX actions
(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;