<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>delusionworld blog &#187; TYPO3</title>
	<atom:link href="http://www.delusionworld.com/category/typo3/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.delusionworld.com</link>
	<description>my MooTools, TYPO3 and FLOW3 experiences</description>
	<lastBuildDate>Sun, 01 Nov 2009 11:57:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>use MooTools in TYPO3 with MPR</title>
		<link>http://www.delusionworld.com/mootools/use-mootools-in-typo3-with-mpr/</link>
		<comments>http://www.delusionworld.com/mootools/use-mootools-in-typo3-with-mpr/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 22:23:54 +0000</pubDate>
		<dc:creator>daKmoR</dc:creator>
				<category><![CDATA[MooTools]]></category>
		<category><![CDATA[TYPO3]]></category>

		<guid isPermaLink="false">http://www.delusionworld.com/?p=128</guid>
		<description><![CDATA[Finally I can present you the combination of my two favorite Open Source Worlds. Meaning MooTools and TYPO3.
MPM comes with a nice TYPO3 Mod where you can look through all the currently installed MooTools Packages with Demos, Doku, Search&#8230; all you need to get it working quite fast 

So let&#8217;s talk about the reason&#8230; I [...]]]></description>
			<content:encoded><![CDATA[<p>Finally I can present you the combination of my two favorite Open Source Worlds. Meaning <strong>MooTools </strong>and <strong>TYPO3</strong>.</p>
<p>MPM comes with a nice TYPO3 Mod where you can look through all the currently installed MooTools Packages with Demos, Doku, Search&#8230; all you need to get it working quite fast <img src='http://www.delusionworld.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<a href="http://www.delusionworld.com/wp-content/uploads/2009/07/MPRinTYPO3.png"><img src="http://www.delusionworld.com/wp-content/uploads/2009/07/MPRinTYPO3-300x189.png" alt="MPRinTYPO3" title="MPRinTYPO3" width="300" height="189" class="alignleft size-medium wp-image-138" style="border: 4px solid #eee;" /></a></p>
<p>So let&#8217;s talk about the <strong>reason</strong>&#8230; I mean I&#8217;m a pretty lazy guy. I don&#8217;t like to do stuff manually if there is any possibility to do it with some sort of automatism. And working on a big TYPO3 site with <strong>multiple MooTools Plugins</strong> can be quite a <strong>pain in the ass</strong>. Every Plugins has it&#8217;s <strong>own MooTools version</strong> and tries to include it. They (usually) don&#8217;t share a common library or don&#8217;t want to require other extensions. I can understand that but it makes my life sometimes harder&#8230; and that&#8217;s something I don&#8217;t like.</p>
<p>So here we come <strong>MPR </strong>as an <strong>TYPO3 extension</strong>. Using MooTools whenever you want to &#8211; no need to think about dependencies or graphics and that stuff.</p>
<div style="background: #eee; font-size: 10px; padding: 5px;">First I wanna say I don&#8217;t want to offend the authors of rgsmoothscroll &#8211; back then it was the best/only way to include MooTools stuff, but now with good use of MPR it could be much easier.</div>
<p>Let&#8217;s see a simple <strong>example</strong>. Maybe you know the extension <strong>rgsmoothscroll </strong>it gives you the smooth scrolling experience for anchor links within one page. It uses the Plugin SmoothScroll (now <strong>Fx.SmoothScroll</strong>) from MooTools More. You can seen an example of it at the <a href="http://mpm.mooforum.net/Mpm.php?mode=demo&#038;file=../mpr/More/Fx/Demos/Fx.SmoothScroll.html">MPR demo page</a> or in your TYPO3 BE Mod (see Screenshot above). Now let&#8217;s take a small look at some of the files in this extension<br />
<em>ext_localconf.php</em> [1 KB] &#8211; register plugin<br />
<em>ext_tables.php</em> [1 KB] &#8211; register statics<br />
<em>res/mootools-1.11.js</em> [21 KB] &#8211; compressed MooTools 1.11<br />
<em>static/constants.txt</em> [1 KB] &#8211; statics for transition, mode, duration, fps<br />
<em>static/setup.txt</em> [1 KB] &#8211; set options from constants and insert plugin on page.91<br />
<em>pi1/class.tx_rgsmoothscroll_pi1.php</em> [4 KB]</p>
<pre class="brush: javascript;">
// [...] could use EXT:t3mootools to build a costum core
// include necessary js
$header .=  '&lt;script type=&quot;text/javascript&quot; src=&quot;'.$this-&gt;getPath($this-&gt;conf['pathToMootools']).'&quot;&gt;&lt;/script&gt;';

$header .= '&lt;script type=&quot;text/javascript&quot;&gt;
	var Page = {
		initialize: function() {
			new SmoothScroll({
				transition: Fx.Transitions.'.$transition.',
				fps: '.intval($conf['fps']).',
				duration: '.intval($conf['duration']).'
			});
		}
	}
	window.addEvent(&quot;domready&quot;, Page.initialize);&lt;/script&gt;';

// include the js in the header
$GLOBALS['TSFE']-&gt;additionalHeaderData['rgsmoothscroll'] = $header;
</pre>
<p>So let&#8217;s explain this a little. First we need to <strong>get all the need JS</strong> this is a <strong>MooTools 1.11</strong> so if I want to use the <strong>MooTools 1.2</strong> features then I have a little problem as I would need to build my own MooTools version and I would need to check out what&#8217;s needed&#8230; it&#8217;s not real a problem but it&#8217;s rather <strong>cumbersome</strong>. I believe the <strong>extension </strong>itself <strong>should not need to care</strong> about the core or MooTools plugin. It should just say I need Smoothscroll and then use it. If the code get&#8217;s included on page render or loaded dynamically shouldn&#8217;t be it conserns. OK let&#8217;s go on &#8211; then we have the <strong>script block</strong> where it starts the <strong>SmoothScroll with all options</strong>. Again it work but it&#8217;s probably not the best way. I mean why give all options &#8211; they are <strong>already well set in the class</strong> itself and if there is another option added in the class you have to mirror it in your extension. Or let&#8217;s say an default value get&#8217;s changed because the funtion of the class is a little modified you would have to update the extension default also&#8230; <strong>doubling data isn&#8217;t good</strong> because you will always have to update at two places&#8230; So I believe options should only be set if you want it expliciply. By default it should use the class defaults and not it own default.</p>
<p>So now let&#8217;s give the &#8220;same&#8221; functionality but with the use of MPR.<br />
ext_localconf.php [1 KB]</p>
<pre class="brush: php;">
t3lib_extMgm::addTypoScript($_EXTKEY,'setup','
page.headerData.989 = TEXT
page.headerData.989.value (
	&lt;script type=&quot;text/javascript&quot;&gt;
		$require(\'Core/Utilities/DomReady.js\');
		$require(\'More/Fx/Fx.SmoothScroll.js\');

		window.addEvent(\'domready\', function() {
			new Fx.SmoothScroll();
		});
	&lt;/script&gt;
)
',43);
</pre>
<p>now what&#8217;s that just one file? yeah it&#8217;s all you need and in fact <strong>I wouldn&#8217;t create an extension for that</strong> but just for the sake of explaination. All we do is to add a script block somewhere on the page. In this block we say that we want to <strong>use </strong>the <strong>DomReady </strong>stuff and the <strong>SmoothScroll </strong>stuff. The we just start SmoothScroll with the default options. No need to care about any other js stuff. No need to include any core or any other css <strong>all </strong>the <strong>info</strong> is <strong>inside </strong>the &#8220;<strong>MooTools Packages</strong>&#8221; itself.<br />
One problem we have with this solution is that if you want to change some options for SmoothScroll you will have to rewrite the whole block&#8230; so I guess we need a <strong>different solution </strong>to the &#8220;<strong>map MooTools option into TS</strong>&#8221; problem&#8230; but more on this <strong>will follow</strong>&#8230;.</p>
<p>So now we see that with MPR it&#8217;s pretty simple to use plugins without even using any extension. Just write the script block prepare some html (if needed) and you are done. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.delusionworld.com/mootools/use-mootools-in-typo3-with-mpr/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
