Neues Design für meinen Blog – oder wie man TV-Framework Skins aus TYPO3 in WordPress nutzt – Teil 3

Mittlerweile wurde eine frühe Version des Skins auf WordPress.org für das theme directory eingereicht.

In der aktuellen Fassung wurde nun das ersetzen der jeweiligen Bereich noch vereinfacht.

Wir haben drei kleine Schritte:

1. initialisieren der Klasse und laden der Default Ersetzungen (Styles, JavaScript für Plugins, etc.)

$helper = new GrabIt_Xml_Helper($options['layoutUri']);
$helper->enableDefaultPostProcessingForWP();

2. Wir definieren was wohin geschrieben werden soll, das pre- und postProcessing wurde nun auf einen Funktionsaufruf gekürzt:

$helper->setPlaceHolder(
  'contentBlock-1',
  GrabIt_Util_Functions::renderSiteContent('page')
);
$helper->setPlaceHolder(
  'contentBlock-2',
  GrabIt_Util_Functions::renderSiteContent('sidebar1')
);
$helper->setPlaceHolder(
  'contentBlock-3',
  GrabIt_Util_Functions::renderSiteContent('sidebar2')
);

3. Im letzten Schritt wird die Seite noch ausgegeben:

echo $helper->parseDocument();

Neues Design für meinen Blog – oder wie man TV-Framework Skins aus TYPO3 in WordPress nutzt – Teil 2

Wie versprochen kommen nun noch einige Details zum “Grabben” des Themes.

<?php

class GrabIt_Xml_Helper {
	protected $prePlaceHolders = array(
		'contentBlock-1' => '##CONTENT-1###',
		'contentBlock-2' => '##CONTENT-2###',
		'contentBlock-3' => '##CONTENT-3###',
		'feature'        => '##FEATURE###',
	);
	protected $postPlaceHolders = array(
		'##CONTENT-1###' => 'content-1',
		'##CONTENT-2###' => 'content-2',
		'##CONTENT-3###' => 'content-3',
		'##FEATURE###'   => 'feature',
		'##FOOTER###'    => 'footer',
		'##MENU###'      => 'menu',
	);
	protected $debug = false;
	function __construct($url) {
		$this->setUrl($url);
	}
	function setUrl($url) {
		$this->url = $url;
	}
	function setPrePlaceHolders($array) {
		$this->prePlaceHolders = $array;
	}
	function setPrePlaceHolder($name, $value) {
		$this->prePlaceHolders[$name] = $value;
	}
	function setPostPlaceHolder($name, $value) {
		$this->postPlaceHolders[$name] = $value;
	}
	function parseDocument() {
		if(!$this->debug === true) {
			$display_errors = ini_get('display_errors');
			ini_set('display_errors', 0);
		}
		$this->dom = new DOMDocument();
		$this->dom->loadHTMLFile($this->url);
		foreach($this->prePlaceHolders as $newNodeId => $placeHolder) {
			$this->replaceNode($newNodeId, $placeHolder);
		}
		if(!$this->debug === true) {
			ini_set('display_errors', $display_errors);
		}
		return $this->getReadyDocumentAsString();
	}
	function replaceNode($newNodeId, $placeHolder) {
		$nodeToReplace = $this->dom->getElementById($newNodeId);
		if($nodeToReplace) {
			$nodeToReplaceParent = $nodeToReplace->parentNode;
			$newNode = new DOMElement('div', $placeHolder);
			$nodeToReplaceParent->replaceChild($newNode, $nodeToReplace);
			$newNode->setAttribute('id', $newNodeId);
		}
	}
	function getReadyDocumentAsString() {
		$buffer = $this->dom->saveHTML();
		foreach($this->postPlaceHolders as $newNodeId => $placeHolder) {
			$buffer = str_replace($newNodeId, $placeHolder, $buffer);
		}
		return $buffer;
	}
}

 

Dank dieser Klasse können einzelne XML Nodes ersetzt werden. Dabei gehe ich zwei Schrittig vor.

  1. Werden die Nodes mit Platzhaltern gefüllt, z.B. ###CONTENT-1###
  2. Im zweiten Schritt kann an die Stelle der Platzhalter normaler HTML Code gesetzt werden

Die zwei Schritte sind nötig, da ansonsten der einzufügende HTML Code valides XML sein muss, da XMLDOM sonst Exceptions wirft.

Um die Klasse zu Verwenden ist dann noch folgender Code nötig:

define('WP_DEBUG', true);

include_once('Classes/Util/Functions.php');

$options = GrabIt_Backend_Setup::getOptions();

$helper = new GrabIt_Xml_Helper($options['layoutUri']);

$helper->setPostPlaceHolder('##CONTENT-1###', UtilFunctions::renderSiteContent('page'));
$helper->setPostPlaceHolder('##CONTENT-2###', UtilFunctions::renderSiteContent('sidebar1'));
$helper->setPostPlaceHolder('##CONTENT-3###', UtilFunctions::renderSiteContent('sidebar2'));
$helper->setPostPlaceHolder('&gt;/head&lt;'        , UtilFunctions::renderSiteContent('head'));

echo $helper->parseDocument();

In den nächsten Tagen werde ich noch folgendes einbauen:

  • Umwandlung relativer Links in absolute Links ;)
  • Erlauben alternativer Settings zu TV Framework und den darauf basierenden Themes

Cheers

Neues Design für meinen Blog – oder wie man TV-Framework Skins aus TYPO3 in WordPress nutzt – Teil 1

Endlich ist meine Seite soweit umgestellt, dass ich auch meinen Blog umstellen kann.

Dabei kommt eine interessante Technik zum Einsatz, ich nutze einfach die Ausgabe von meinem TYPO3 ;)

Dazu habe ich mir ein Theme geschrieben, mit dem ich das Layout von Webseiten, die mit TemplaVoilaFramework erstellt worden in WordPress importieren kann. Die “Generated Content” Bereiche werden dabei automatisch zu Sidebars umgewandelt. Das Prinzip läßt sich mit Sicherheit auch auf andere Layout Frameworks übertragen, da die Klassen sehr frei konfigurierbar sind.

Derzeit gibt es noch einige kleinere Probleme mit SubTemplates und dem BlogStructureCSS, aber das wird noch gelöst ;)

Cheers

HTTPS mit SSL Proxy für WordPress

So kann man WordPress mit SSL nutzen:

  1. öffnen der Datei wp-config.php
  2. einfügen des folgenden Codes vor dem Kommentar Stop editing
    Die Variable Domain gibt die Hauptdomain des Blogs an.

    //ssl patch begin
    	$domain = 'blog.kay-strobach.de';
    	if($_SERVER['HTTP_X_FORWARDED_HOST']=="ssl.webpack.de") {
    				// mit SSL-oxy
    			define('WP_SITEURL', 'https://ssl.webpack.de/' . $domain);
    			define('WP_HOME', 'https://ssl.webpack.de/' . $domain);
    			$_SERVER['HTTPS'] = 'on';
    			$_SERVER['REQUEST_URI'] = '/' . $domain . $_SERVER['REQUEST_URI'];
    	} else {
    				// Ohne SSLroxy
    			define('WP_SITEURL', 'http://' . $domain);
    			define('WP_HOME', 'http://' . $domain);
    	}
    //ssl patch end
    

    und schon ist es erledigt …

Aloha editor im TYPO3 Backend

Based on the discussion on the TYPO3v4 List:

http://lists.typo3.org/pipermail/typo3-project-v4/2011-July/002519.html

I started to implement an early prototype of aloha editor in the TYPO3 Backend:

You may download the extension below. All other rte’s must be deactivated.

T3X_aloha-0_1_0-z-201107041851

Please note, this software is an early alpha – Please do not use it in an production environment. I do not guarentee, that is works completly.

Current features:

  • Basic Aloha editor in Backend
  • Saving works

Must have features (currently missing):

  • Optimizing code to be smaller (currently based on tinemce_rte)
  • Link Wizard
  • Table Wizard
  • CSS Class Wizard
  • other

Regards

Kay

Nächste Seite »