TYPO3 Backend Hook (i.e. geocoding)

EXT.local_conf.php

$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:storefinder/Classes/BackendHooks/GeocodeAddress.php:GeocodeAddress';

EXT:Classes/BackendHooks/

class GeocodeAddress 
{
	protected $conf  = array();
	
	function processDatamap_afterDatabaseOperations ($status, $table, $id, $fieldArray, &$pObj) 
	{
		if($table == 'tx_storefinder_domain_model_storefinder') 
		{
			$id = (substr($id, 0, 3) == "NEW") ? $pObj->substNEWwithIDs[$id] : $id;
			$row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord ($table, $id);
			$address = urlencode($row['sf_street']." ".$row['sf_housenumber'].",".$row['sf_zip']." ".$row['sf_city'].",".$row['sf_country']);
			$url = "http://maps.googleapis.com/maps/api/geocode/json?address=".$address."&sensor=false&language=de";	
			
			// $dataRaw = @file_get_contents($url);
			$curl = curl_init();
			curl_setopt($curl, CURLOPT_HEADER, 0);
			curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($curl, CURLOPT_URL, $url);
			$dataRaw = curl_exec($curl);
			curl_close($curl);

			$data = json_decode($dataRaw, true);

			if($data['status'] == 'OVER_QUERY_LIMIT') 
			{
				die($data['error_message']);
			}

			$fieldArray['sf_latitude'] = $data['results'][0]['geometry']['location']['lat'];
			$fieldArray['sf_longitude'] = $data['results'][0]['geometry']['location']['lng'];
			$update = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_storefinder_domain_model_storefinder','uid='.$id , $fieldArray); 
		}
	}
} 

TYPO3 TCA Backend Felder Gruppieren

Anzupassen in der ext_tables.php

<?php

if (!defined('TYPO3_MODE')) {
 die('Access denied.');
}

// Adding fields to pages TCA
$tmpCol = array(

 'additional_data_facebook_share_image' => array(
 'label' => 'Share-Image (og:image) / Bild beim Posten des Links',
 'config' => array(
 'type' => 'group',
 'internal_type' => 'file',
 'allowed' => 'gif,jpeg,jpg,png',
 'uploadfolder' => 'uploads/pics/',
 'show_thumbs' => "1",
 'size' => "1",
 'minitems' => "0",
 'maxitems' => "1"
 )
 ),
 'additional_data_geo_latitude' => array(
 'label' => 'Latitude (z.B. 48.779209)',
 "config" => Array (
 "type" => "input",
 "size" => "20",
 "eval" => "trim"
 )
 ), 
 'additional_data_geo_longitude' => array(
 'label' => 'Longitude (z.B. 9.17721522)',
 "config" => Array (
 "type" => "input",
 "size" => "20",
 "eval" => "trim"
 )
 ),
);


t3lib_extMgm::addTCAcolumns('pages', $tmpCol, 1);

$TCA['pages']['palettes']['additional_data_facebook'] = array(
 'showitem' => 'additional_data_facebook_share_image',
 'canNotCollapse' => 1
);

$TCA['pages']['palettes']['additional_data_geo'] = array(
 'showitem' => 'additional_data_geo_latitude,additional_data_geo_longitude',
 'canNotCollapse' => 1
);

t3lib_extMgm::addToAllTCAtypes( 'pages', '--div--;Zusätzliche Daten;,--palette--;Facebook;additional_data_facebook,--palette--;Geodaten;additional_data_geo','', 'after:author_email');

?>

Performance Fix für feste Hintergrundbilder

Das Problem:
Die Angaben background-attachment:fixed und background-size:cover sorgen für ein großes Performance Problem.

container
{
  background: url('/img/front/strategy.jpg') no-repeat center center;
  background-attachment: fixed;
  background-size: cover;
}

Die Lösung:
Ein Pseudo-Container welcher fixed positioniert wird anstatt eines Bild es mit background-attachment:fixed.

.container
{
  overflow: hidden; // added for pseudo-element
  position: relative; // added for pseudo-element
}
.container:before 
{
    content: ' ';
    position: fixed; // instead of background-attachment
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: url('/img/front/strategy.jpg') no-repeat center center;
    background-size: cover;
    z-index: -1;
}