<?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>Nerdpress.org</title>
	<atom:link href="http://www.nerdpress.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nerdpress.org</link>
	<description>^__^</description>
	<lastBuildDate>Thu, 03 May 2012 15:03:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Silverstripe Profilable module</title>
		<link>http://www.nerdpress.org/2012/05/03/silverstripe-profilable-module/</link>
		<comments>http://www.nerdpress.org/2012/05/03/silverstripe-profilable-module/#comments</comments>
		<pubDate>Thu, 03 May 2012 15:03:19 +0000</pubDate>
		<dc:creator>Ivo Bathke</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Silverstripe]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=2172</guid>
		<description><![CDATA[This is a reoccuring requirement: you need a profile for some object in your project. FE you have a company, a member or a location that should get an address, a marker on the map, an icon, homepage etc. So I created a small silverstripe module that adds a profile tab to any object you [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>This is a reoccuring requirement: you need a profile for some object in your project.<br />
FE you have a company, a member or a location that should get an address, a marker on the map, an icon, homepage etc.</p>
<p>So I created a small <a href="https://github.com/ivoba/silverstripe-profileable" title="silverstripe-profileable">silverstripe module that adds a profile tab</a> to any object you choose in your Silverstripe CMS backend.</p>
<p><a href="http://nerdpress.org/wp-content/uploads/2012/05/silverstripe-profilable.png" rel="lightbox[post-2172]" title=""><img src="http://nerdpress.org/wp-content/uploads/2012/05/silverstripe-profilable-300x129.png" alt="Silverstripe-profilable-300x129 in Silverstripe Profilable module" width="300" height="129" class="alignnone size-medium wp-image-2174" /></a><br />
<span id="more-2172"></span><br />
It basically extends the very handy <a href="https://github.com/ajshort/silverstripe-addressable" title="silverstripe-addressable">addressable module</a> and inherits all functionality from it like automatic geocoding, regex field to validate postcodes, set allowed countries and rendering of a static google map.<br />
If you just need an Address I recommend to use the addressable module.</p>
<p>Install it easy by:<br />
Simply extend your Object in your _config.php:</p>
<pre class="brush: php; title: ; notranslate">Object::add_extension('myObject', 'Profileable');</pre>
<p>To add the automatic geocoding add:</p>
<pre class="brush: php; title: ; notranslate">Object::add_extension('myObject', 'Geocodable');</pre>
<p>and of course run: <em>dev/build?flush=all</em></p>
<p>It also renders the profile in semantic hContact mircroformat markup, just place <em>$getFullProfileHTML</em> in your template and style it.<br />
If you want to render the Profile different just copy the <em>Profile.ss</em> over to your theme and start editing.</p>
<p>Read more in the readme&#8217;s :)</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.nerdpress.org/2012/05/03/silverstripe-profilable-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hosting multiple Express (node.js) apps on port 80</title>
		<link>http://www.nerdpress.org/2012/04/20/hosting-multiple-express-node-js-apps-on-port-80/</link>
		<comments>http://www.nerdpress.org/2012/04/20/hosting-multiple-express-node-js-apps-on-port-80/#comments</comments>
		<pubDate>Fri, 20 Apr 2012 03:40:31 +0000</pubDate>
		<dc:creator>Max Girkens</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[Express]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[socket.io]]></category>
		<category><![CDATA[vServer]]></category>
		<category><![CDATA[express]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[sockets]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=2144</guid>
		<description><![CDATA[In the last days, i was trying to find a solution hosting multiple Express apps on my vServer the same Server. Starting with Apache and mod_proxy, i ended up with a plain node solution, which i really like. Let&#8217;s take a quick look on some different approaches out there: &#8212;1&#8212; Using apache on port 80 [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>In the last days, i was trying to find a solution hosting multiple <a href="http://expressjs.com/">Express</a> apps on <del datetime="2012-04-19T00:40:35+00:00">my vServer </del>the same Server.</p>
<p>Starting with <a href="http://www.apache.org/">Apache</a> and <a href="http://httpd.apache.org/docs/2.0/mod/mod_proxy.html">mod_proxy</a>, i ended up with a plain node solution, which i really like.<span id="more-2144"></span></p>
<p><a href="http://nerdpress.org/wp-content/uploads/2012/04/node-http-proxy-haz-colors.png" rel="lightbox[post-2144]" title=""><img class="alignnone size-full wp-image-2146" src="http://nerdpress.org/wp-content/uploads/2012/04/node-http-proxy-haz-colors.png" alt="Node-http-proxy-haz-colors in Hosting multiple Express (node.js) apps on port 80" width="527" height="106" /></a></p>
<p>Let&#8217;s take a quick look on some different approaches out there:</p>
<p><strong>&#8212;1&#8212;</strong></p>
<p>Using apache on port 80 as a proxy</p>
<pre class="brush: bash; title: ; notranslate">
ProxyPass /nodeurls/ http://localhost:9000/
ProxyPassReverse /nodeurls/ http://localhost:9000/
</pre>
<p>via <a href="http://stackoverflow.com/questions/6109089/how-do-i-run-node-js-on-port-80">stackoverflow</a></p>
<p>&#8211; no websockets<br />
++ probably the easiest way to integrate with your running AMPP-stack</p>
<p><strong>&#8212;2&#8212;</strong></p>
<p>Using a node.js app on port 80 as a Wrapper for other node apps.</p>
<pre class="brush: jscript; title: ; notranslate">
express.createServer()
  .use(express.vhost('hostname1.com', require('/path/to/hostname1').app)
  .use(express.vhost('hostname2.com', require('/path/to/hostname2').app)
.listen(80)
</pre>
<p>via <a href="http://stackoverflow.com/questions/9332865/how-should-i-organize-multiple-express-servers-on-the-same-system">stackoverflow</a></p>
<p>++ you can use websockets on port 80<br />
&#8211; apps crash/restart/stop globally<br />
&#8211;what about your apache or the like?</p>
<p><strong>&#8212;3&#8212;</strong></p>
<p>Using node.js with node-http-proxy on port 80</p>
<pre class="brush: jscript; title: ; notranslate">
var http = require('http')
, httpProxy = require('http-proxy');

httpProxy.createServer({
  hostnameOnly: true,
  router: {
    //web-development.cc
    'www.my-domain.com': '127.0.0.1:3001',
    'www.my-other-domain.de' : '127.0.0.1:3002'
  }
}).listen(80);
</pre>
<p>++ proxy websockets to any port<br />
&#8211; you might need to move your old web server to another port</p>
<p>The really cool thing about using node-http-proxy is its capability of proxying websockets.<br />
So you can have your apps running independtly on different ports while serving everything to the user over port 80 and use stuff like <a href="http://socket.io/">socket.io</a>.</p>
<p>Since i&#8217;m new to node.js and miles away from beeing a admin, any feedback is highly appreciated :)</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.nerdpress.org/2012/04/20/hosting-multiple-express-node-js-apps-on-port-80/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>how to add placeholder attributes in Silverstripe Userforms Module</title>
		<link>http://www.nerdpress.org/2012/04/19/how-to-add-placeholder-attributes-in-silverstripe-userforms-module/</link>
		<comments>http://www.nerdpress.org/2012/04/19/how-to-add-placeholder-attributes-in-silverstripe-userforms-module/#comments</comments>
		<pubDate>Thu, 19 Apr 2012 04:32:28 +0000</pubDate>
		<dc:creator>Max Girkens</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Silverstripe]]></category>
		<category><![CDATA[placeholder]]></category>
		<category><![CDATA[UserForm]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=2160</guid>
		<description><![CDATA[to be honest i didn&#8217;t find a clean way yet, but i thought this workaround might be worth sharing. &#8230;since Silverstripes&#8216; Userforms Module Uses jQuery for Validation you can put these lines of code in your UserDefinedForm.ss Template: This will iterate over the labels in the form , build placeholder attributes from each one and [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>to be honest i didn&#8217;t find a clean way yet, but i thought this workaround might be worth sharing.</p>
<p>&#8230;since <a href="http://www.silverstripe.org/">Silverstripes</a>&#8216; <a href="http://www.silverstripe.org/user-forms-module/">Userforms Module</a> Uses jQuery for Validation you can put these lines of code in your UserDefinedForm.ss Template:<span id="more-2160"></span></p>
<pre class="brush: jscript; title: ; notranslate">
jQuery(document).ready(function(){
    jQuery('form label').each(function(){
      jQuery(this).parent().find('input, textarea').attr('placeholder', jQuery(this).html());
      jQuery(this).remove();
    })
  });
</pre>
<p>This will iterate over the labels in the form , build placeholder attributes from each one and then remove it.</p>
<p>If anyone knows a way how to do this in PHP, i&#8217;d appreciate a comment :)</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.nerdpress.org/2012/04/19/how-to-add-placeholder-attributes-in-silverstripe-userforms-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>javascript benchmarking with jsperf</title>
		<link>http://www.nerdpress.org/2012/04/11/javascript-benchmarking-with-jsperf/</link>
		<comments>http://www.nerdpress.org/2012/04/11/javascript-benchmarking-with-jsperf/#comments</comments>
		<pubDate>Wed, 11 Apr 2012 15:18:31 +0000</pubDate>
		<dc:creator>Ivo Bathke</dc:creator>
				<category><![CDATA[JS]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=2139</guid>
		<description><![CDATA[I might be a bit late (yeaikno it exist over a year now and a bunch of blogs had it covered) but nevertheless i would like to point out a very helpful online tool i recently ran into: jsPerf Its basically a online benchmark tool for testing different approaches in javascript. It covers some important [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>I might be a bit late <del datetime="2012-04-11T15:12:28+00:00">(yeaikno it exist over a year now and a bunch of blogs had it covered)</del> but nevertheless i would like to point out a very helpful online tool i recently ran into:</p>
<p><a href="http://jsperf.com" target="_blank">jsPerf</a></p>
<p>Its basically a online benchmark tool for testing different approaches in javascript.<br />
It covers some important aspects of benchmarking, that your homemade bench probably wont have like milliseconds accuracy &#038; statistical analysis.<br />
The tests are run on your browser and the results will feed the &#8220;browserscope&#8221;. A graph of the &#8220;highest known results&#8221; for the participating browsers.<br />
So we can see some kind of comparison.<br />
<span id="more-2139"></span><br />
Almost all classic concurrent approaches are covered, my favorites are:</p>
<p><a href="http://jsperf.com/string-concatenation/14" target="_blank">String concatenation</a></p>
<p><a href="http://jsperf.com/javascript-template-engine/3" target="_blank">JavaScript Template Engines</a>, in this revision its: juicer, mustache, ejohn, kissy, nTenjin<br />
( yes it has revisions :) )</p>
<p><a href="http://jsperf.com/switchclass-or-removeclass-and-addclass" target="_blank">switchClass OR removeClass and addClass</a></p>
<p><a href="http://jsperf.com/jquery-remove-class-selector" target="_blank">fastest jQuery selectors to remove class</a></p>
<p>See if you can find some, you struggled with lately:<br />
<a href="http://jsperf.com/browse" target="_blank">http://jsperf.com/browse</a></p>
<p>JsPerf has some further interesting options like<br />
<strong>autorun</strong><br />
<em>append #run to the URL of the test case</em></p>
<p><strong>filters</strong> for the browserscope<br />
<em>filters are: popular, all, desktop, family, major, minor, mobile, prerelease</em></p>
<p><strong>chart types</strong> of browserscope<br />
<em>append #chart=table to the test case’s URL<br />
types are: bar(default), table, column, line, and pie</em></p>
<p>Give it a try, daily!</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.nerdpress.org/2012/04/11/javascript-benchmarking-with-jsperf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tools for jade template development</title>
		<link>http://www.nerdpress.org/2012/04/09/tools-for-jade-template-development/</link>
		<comments>http://www.nerdpress.org/2012/04/09/tools-for-jade-template-development/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 10:12:01 +0000</pubDate>
		<dc:creator>Max Girkens</dc:creator>
				<category><![CDATA[Express]]></category>
		<category><![CDATA[Jade]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[express]]></category>
		<category><![CDATA[jade]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=2132</guid>
		<description><![CDATA[I recently started digging into node.js and the express framework. One thing i like about it is that it comes with the beautiful jade template engine by default. Here are some things that come real hany when you are working with jade. This one really saved my mental health in more than one case. Just [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>I recently started digging into <a href="http://nodejs.org/">node.js</a> and the <a href="http://expressjs.com/">express framework</a>.<br />
One thing i like about it is that it comes with the beautiful <a href="http://jade-lang.com/">jade template engine</a> by default.</p>
<p>Here are some things that come real hany when you are working with jade.<span id="more-2132"></span></p>
<p>This one really saved my mental health in more than one case.<br />
Just paste your HTML and you get nice and clean jade code:</p>
<p><a href="http://html2jade.aaron-powell.com/">http://html2jade.aaron-powell.com/</a></p>
<p>If you are using Netbeans, make sure you don&#8217;t miss to install the beautifully working plugin for .jade files.</p>
<p><a href="https://github.com/lumenlunae/jade-netbeans-syntax-highlighting">https://github.com/lumenlunae/jade-netbeans-syntax-highlighting</a></p>
<p>If you are developing in PHP and want to check out jade anyway, check this out:</p>
<p><a href="http://nerdpress.org/wp-content/uploads/2012/04/php_jade.jpg" rel="lightbox[post-2132]" title=""><img class="alignnone size-full wp-image-2135" src="http://nerdpress.org/wp-content/uploads/2012/04/php_jade.jpg" alt="Php Jade in Tools for jade template development" width="293" height="238" /></a></p>
<p>No seriously, check THIS:</p>
<p><a href="https://github.com/everzet/jade.php">https://github.com/everzet/jade.php</a></p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.nerdpress.org/2012/04/09/tools-for-jade-template-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Symfony 2] composer.json for a assumed-stable symfony 2 distribution</title>
		<link>http://www.nerdpress.org/2012/04/01/symfony-2-composer-json-for-a-assumed-stable-symfony-2-distribution/</link>
		<comments>http://www.nerdpress.org/2012/04/01/symfony-2-composer-json-for-a-assumed-stable-symfony-2-distribution/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 12:18:54 +0000</pubDate>
		<dc:creator>Johannes Heinen</dc:creator>
				<category><![CDATA[Doctrine ORM]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Project Setup]]></category>
		<category><![CDATA[Silex]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Twig]]></category>
		<category><![CDATA[composer.phar]]></category>
		<category><![CDATA[dependency management]]></category>
		<category><![CDATA[packagist]]></category>
		<category><![CDATA[symfony 2]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=2118</guid>
		<description><![CDATA[This small composer.json file is used in a project i am working on atm, feel free to use it at own risk. I will provide non-periodical updates and hopefully soon a full upgrade to symfony 2.1.x including doctrine orm 2.2.x. I still did not get the point regarding dependency resolution, so i simply &#8220;composed&#8221; the [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>This small composer.json file is used in a project i am working on atm, feel free to use it at own risk. I will provide non-periodical updates and hopefully soon a full upgrade to symfony 2.1.x including doctrine orm 2.2.x.</p>
<p>I still did not get the point regarding dependency resolution, so i simply &#8220;composed&#8221; the composer file by writing down my own requirements (&#8220;i want only the hottest, newest stuff!!&#8221;, then tracked down the error messages, removing them by explicetly writing down the missing dependencies by using the latest &#8220;dev-*&#8221; versions. After that i tried to run the project, which actually did not work, but selective downgrade of some of the bundles (framework, security-extra blahblah) finally did the job.<span id="more-2118"></span></p>
<p>Feel free to use it in your own projects:</p>
<pre class="brush: jscript; title: ; notranslate">
{
	&quot;require&quot; : {
              &quot;symfony/symfony&quot; : &quot;v2.0.12&quot;,
              &quot;doctrine/common&quot; : &quot;2.1.4&quot;,
              &quot;doctrine/orm&quot; : &quot;2.1.6&quot;,
              &quot;symfony/finder&quot; : &quot;v2.0.12&quot;,

              &quot;symfony/assetic-bundle&quot; : &quot;2.0-dev&quot;,
              &quot;twig/extensions&quot; : &quot;dev-master&quot;,
              &quot;jms/security-extra-bundle&quot; : &quot;1.1.0&quot;,
              &quot;sensio/framework-extra-bundle&quot; : &quot;2.0-dev&quot;,
              &quot;sensio/distribution-bundle&quot; : &quot;2.0-dev&quot;,
              &quot;sensio/generator-bundle&quot; : &quot;2.0-dev&quot;

 	},
        &quot;autoload&quot; : {
            &quot;psr-0&quot; : {
                &quot;Acme&quot; : &quot;src/&quot;,
            }
        }
}
</pre>
<p>Create a file named &#8220;composer.json&#8221; in your project&#8217;s root directory, then paste the above code into it and save it.</p>
<p>Now run</p>
<pre class="brush: bash; title: ; notranslate">
$ curl -s http://getcomposer.org/installer | php
</pre>
<p>After that, download all dependencies by typing</p>
<pre class="brush: bash; title: ; notranslate">
$ php composer.phar install
</pre>
<p>The easiest way to create a full project including AcmeDemoBundle, AppKernel and the whole stuff is to download the symfony 2 standard distribution without vendors and calling the script from there. The only thing to do is to modify the path to autoload.php, which should point to vendor/.composer/autoload.php.</p>
<p>Now you are able to upgrade your project&#8217;s dependencies to the newest versions by simply modifying the composer.json file. Have fun!.</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.nerdpress.org/2012/04/01/symfony-2-composer-json-for-a-assumed-stable-symfony-2-distribution/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>run JavaScript code in PHP 5.3 with the v8js extension</title>
		<link>http://www.nerdpress.org/2012/03/09/run-javascript-code-in-php-5-3-with-the-v8js-extension/</link>
		<comments>http://www.nerdpress.org/2012/03/09/run-javascript-code-in-php-5-3-with-the-v8js-extension/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 23:14:10 +0000</pubDate>
		<dc:creator>Max Girkens</dc:creator>
				<category><![CDATA[JS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[homebrew]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[pecl]]></category>
		<category><![CDATA[v8js.so]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=2102</guid>
		<description><![CDATA[&#8230;for some reason i needed to get t h i s to work before going to sleep. I&#8217;m running OSX 10.7.3 with macports which usually does the job, but  Google&#8217;s V8 Javascript Engine is not available as a port yet. So&#8230; homebrew to the rescue: installed it: and installed v8 wait, this seems too easy. [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>&#8230;for some reason i needed to get <strong><a href="http://php.net/manual/en/book.v8js.php">t h i s</a></strong> to work before going to sleep.</p>
<p>I&#8217;m running OSX 10.7.3 with <a href="http://www.macports.org/">macports</a> which usually does the job, but  <a href="http://code.google.com/p/v8/">Google&#8217;s V8 Javascript Engine</a> is not available as a port yet.<span id="more-2102"></span></p>
<p>So&#8230; <a href="http://mxcl.github.com/homebrew/">homebrew</a> to the rescue:</p>
<p>installed it:</p>
<pre class="brush: bash; title: ; notranslate">
/usr/bin/ruby -e &quot;$(/usr/bin/curl -fsSL https://raw.github.com/gist/323731)&quot;
</pre>
<p>and installed v8</p>
<pre class="brush: bash; title: ; notranslate">
brew install v8
</pre>
<p>wait, this seems <a href="http://www.youtube.com/watch?v=jWI8w9kLAks">too easy</a>.</p>
<p>PECL installed some beta version of the PHP extension.</p>
<pre class="brush: bash; title: ; notranslate">
sudo pecl install channel://pecl.php.net/v8js-0.1.2
</pre>
<p>added</p>
<pre class="brush: bash; title: ; notranslate">extension=v8js.so</pre>
<p>to the php.ini file.</p>
<p>und bitteschön:</p>
<pre class="brush: php; title: ; notranslate">

$v8 = new V8Js();
var_dump($v8-&gt;executeString(&quot;

//hey i'm Javascript Code

//INSIDE PHP !

//wow.
var hello = 'Hallo';

function helloWorld( string ){
return hello + ' ' + string;
}

helloWorld('World');

&quot;));
</pre>
<p>Such things might come in handy one day, <a href="https://plus.google.com/115423703838305233565/posts/VtskgWhB3kV">you know</a>.</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.nerdpress.org/2012/03/09/run-javascript-code-in-php-5-3-with-the-v8js-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverstripe &#8211; has_many- and many_many-relations when duplicating pages</title>
		<link>http://www.nerdpress.org/2012/03/07/silverstripe-has-many-and-many-many-relations-when-duplicating-pages/</link>
		<comments>http://www.nerdpress.org/2012/03/07/silverstripe-has-many-and-many-many-relations-when-duplicating-pages/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 03:48:03 +0000</pubDate>
		<dc:creator>Max Girkens</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Silverstripe]]></category>
		<category><![CDATA[duplicate pages]]></category>
		<category><![CDATA[has_many]]></category>
		<category><![CDATA[many_many]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=2087</guid>
		<description><![CDATA[When you duplicate a page in the Silverstripe Sitetree, related &#8220;has_one&#8221; Items are automatically copied, which is nice. But if you have, lets say, multiple related images on that Page, those are not copied when you duplicate that Page. After reading this discussion, i found out that it&#8217;s actually pretty easy to &#8220;fix&#8221; this. This [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>When you duplicate a page in the <a href="http://www.silverstripe.org/">Silverstripe</a> Sitetree, related &#8220;has_one&#8221; Items are automatically copied, which is nice.</p>
<p>But if you have, lets say, multiple related images on that Page, those are not copied when you duplicate that Page.<span id="more-2087"></span></p>
<p>After reading <a href="http://www.silverstripe.org/data-model-questions/show/17342?start=8">this discussion</a>, i found out that it&#8217;s actually pretty easy to &#8220;fix&#8221; this.</p>
<p>This what i ended up with and seems to be working fine:</p>
<pre class="brush: php; title: ; notranslate">
//assuming your page has the following related Dataobjects

public static $has_many = array(
'Images' =&gt; 'MyImageDataObject'
);

public static $many_many = array(
'Something' =&gt; 'AnotherPageTypeOrWhatever

);
</pre>
<p>The following code would automatically duplicate the has_many related DataObjects<br />
and just set the relation to the many_many Objects on the created page:</p>
<pre><div id="gist-2014023" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="cp">&lt;?php</span> </div><div class='line' id='LC2'><br/></div><div class='line' id='LC3'><span class="k">public</span> <span class="k">function</span> <span class="nf">duplicate</span><span class="p">()</span> <span class="p">{</span></div><div class='line' id='LC4'>&nbsp;</div><div class='line' id='LC5'>&nbsp;&nbsp;<span class="nv">$items_to_duplicate</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span></div><div class='line' id='LC6'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="s1">&#39;Images&#39;</span><span class="p">,</span></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="s1">&#39;Somehting&#39;</span></div><div class='line' id='LC8'>&nbsp;&nbsp;<span class="p">);</span></div><div class='line' id='LC9'>&nbsp;</div><div class='line' id='LC10'>&nbsp;&nbsp;<span class="nv">$page</span> <span class="o">=</span> <span class="k">parent</span><span class="o">::</span><span class="na">duplicate</span><span class="p">();</span></div><div class='line' id='LC11'>&nbsp;</div><div class='line' id='LC12'>&nbsp;&nbsp;<span class="c1">//duplicate has many items</span></div><div class='line' id='LC13'>&nbsp;&nbsp;<span class="k">foreach</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">has_many</span><span class="p">()</span> <span class="k">as</span> <span class="nv">$key</span> <span class="o">=&gt;</span> <span class="nv">$className</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC14'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nb">in_array</span><span class="p">(</span><span class="nv">$key</span><span class="p">,</span> <span class="nv">$items_to_duplicate</span><span class="p">))</span> <span class="p">{</span></div><div class='line' id='LC15'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">foreach</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="p">{</span><span class="nv">$key</span><span class="p">}()</span> <span class="k">as</span> <span class="nv">$item</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC16'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nv">$newField</span> <span class="o">=</span> <span class="nv">$item</span><span class="o">-&gt;</span><span class="na">duplicate</span><span class="p">();</span></div><div class='line' id='LC17'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nv">$id</span> <span class="o">=</span> <span class="nb">get_class</span><span class="p">(</span><span class="nv">$this</span><span class="p">)</span> <span class="o">.</span> <span class="s1">&#39;ID&#39;</span><span class="p">;</span></div><div class='line' id='LC18'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nv">$newField</span><span class="o">-&gt;</span><span class="p">{</span><span class="nv">$id</span><span class="p">}</span> <span class="o">=</span> <span class="nv">$page</span><span class="o">-&gt;</span><span class="na">ID</span><span class="p">;</span></div><div class='line' id='LC19'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nv">$newField</span><span class="o">-&gt;</span><span class="na">write</span><span class="p">();</span></div><div class='line' id='LC20'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC21'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC22'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC23'>&nbsp;</div><div class='line' id='LC24'>&nbsp;&nbsp;<span class="c1">//set the relation to many_many items on created page</span></div><div class='line' id='LC25'>&nbsp;&nbsp;<span class="k">foreach</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">many_many</span><span class="p">()</span> <span class="k">as</span> <span class="nv">$key</span> <span class="o">=&gt;</span> <span class="nv">$className</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC26'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nb">in_array</span><span class="p">(</span><span class="nv">$key</span><span class="p">,</span> <span class="nv">$items_to_duplicate</span><span class="p">))</span> <span class="p">{</span></div><div class='line' id='LC27'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nv">$page</span><span class="o">-&gt;</span><span class="p">{</span><span class="nv">$key</span><span class="p">}()</span><span class="o">-&gt;</span><span class="na">addMany</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="p">{</span><span class="nv">$key</span><span class="p">}()</span><span class="o">-&gt;</span><span class="na">getIdList</span><span class="p">());</span></div><div class='line' id='LC28'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC29'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC30'>&nbsp;</div><div class='line' id='LC31'>&nbsp;&nbsp;<span class="k">return</span> <span class="nv">$page</span><span class="p">;</span></div><div class='line' id='LC32'><span class="p">}</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2014023/9d77984e4827c16032bcc39eb270ee8be5f69c90/silverstripe_duplicate_relations.php" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2014023#file_silverstripe_duplicate_relations.php" style="float:right;margin-right:10px;color:#666">silverstripe_duplicate_relations.php</a>
            <a href="https://gist.github.com/2014023">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>
</pre>
<p>..as already suggested <a href="http://www.silverstripe.org/data-model-questions/show/17342?start=8">in the forum</a>, i still think this would make a handy core feature, wouldn&#8217;t it?<br />
Would be cool to globally specify relations to duplicate in the page-config with something like</p>
<pre class="brush: php; title: ; notranslate">
public static $relations_to_copy = array(
 'Images',
 'Somehting'
);
</pre>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.nerdpress.org/2012/03/07/silverstripe-has-many-and-many-many-relations-when-duplicating-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>modulo in Twig</title>
		<link>http://www.nerdpress.org/2012/02/14/modulo-in-twig/</link>
		<comments>http://www.nerdpress.org/2012/02/14/modulo-in-twig/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 16:05:48 +0000</pubDate>
		<dc:creator>Ivo Bathke</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Twig]]></category>
		<category><![CDATA[symfony 2]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=2078</guid>
		<description><![CDATA[Ever wondered how to use the modulo operator in twig, the template engine of symfony? Actually its like in PHP: As described here But i guess for most use cases modulus is used to check if a number is divisible by another number. Therefore Twig has the very conveniant divisibleby test function. Another modulo use [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Ever wondered how to use the <strong>modulo</strong> operator in twig, the template engine of symfony?</p>
<p>Actually its like in PHP:</p>
<pre class="brush: php; title: ; notranslate">{{ 11 % 7 }}</pre>
<p>As described <a href="http://twig.sensiolabs.org/doc/templates.html#math">here</a> </p>
<p>But i guess for most use cases <strong>modulus</strong> is used to check if a number is divisible by another number.<br />
Therefore Twig has the very conveniant <a href="http://twig.sensiolabs.org/doc/tests/divisibleby.html">divisibleby</a> test function.</p>
<pre class="brush: php; title: ; notranslate">{% if loop.index is divisibleby(3) %}</pre>
<p><span id="more-2078"></span><br />
Another modulo use case is to check odd and even rows in loops. There Twig has the built-in function <a href="http://twig.sensiolabs.org/doc/functions/cycle.html">cycle</a> to help you.</p>
<pre class="brush: php; title: ; notranslate">{{ cycle(['odd', 'even'], i) }}</pre>
<p>Once you know its so eeasy;)</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.nerdpress.org/2012/02/14/modulo-in-twig/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Silverstripe Setup Script</title>
		<link>http://www.nerdpress.org/2012/02/09/silverstripe-setup-script/</link>
		<comments>http://www.nerdpress.org/2012/02/09/silverstripe-setup-script/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 09:30:42 +0000</pubDate>
		<dc:creator>Ivo Bathke</dc:creator>
				<category><![CDATA[Project Setup]]></category>
		<category><![CDATA[Silverstripe]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[Setup]]></category>

		<guid isPermaLink="false">http://nerdpress.org/?p=2041</guid>
		<description><![CDATA[We thought we had to improve our SilverStripe setup script for our development environment. So Max and me rewrote it to add submodules and some other improvements. Just run: and you have silverstripe project folder structure the tutorial theme a already filled git repository sapphire as submodule cms as submodule Uploadify as submodule DataObjectManager as [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>We thought we had to improve our <a href="http://nerdpress.org/2011/09/11/install-silverstripe-with-some-modules-from-git/">SilverStripe setup script</a> for our development environment.<br />
So <a href="http://web-development.cc">Max</a> and me rewrote it to add submodules and some other improvements.</p>
<p>Just run:</p>
<pre class="brush: bash; title: ; notranslate">
./install_silverstripe.sh mynewproject tags/2.4.7
</pre>
<p>and you have</p>
<ul>
<li>silverstripe project folder structure</li>
<li>the tutorial theme</li>
<li>a already filled git repository</li>
<li>sapphire as submodule</li>
<li>cms as submodule</li>
<li>Uploadify as submodule</li>
<li>DataObjectManager as submodule</li>
<li>UserForms as submodule</li>
</ul>
<p><span id="more-2041"></span></p>
<p>What you then still need to do is:</p>
<ul>
<li>create the database</li>
<li>setup a local vhost</li>
<li>open your project url and run the install process</li>
<li>start to code</li>
</ul>
<p>So here it is:<br />
<div id="gist-1768946" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="c"># install silverstripe + common modules from github</span></div><div class='line' id='LC2'><span class="c"># usage sh install_silverstripe.sh &lt;folder_name&gt; &lt;tag/branch&gt;</span></div><div class='line' id='LC3'><span class="c"># examples: </span></div><div class='line' id='LC4'><span class="c"># sh install_silverstripe.sh some_folder tags/2.4.5</span></div><div class='line' id='LC5'><span class="c"># sh install_silverstripe.sh some_folder master</span></div><div class='line' id='LC6'><br/></div><div class='line' id='LC7'><span class="c">#set up project base folder</span></div><div class='line' id='LC8'>git clone git@github.com:silverstripe/silverstripe-installer.git <span class="nv">$1</span></div><div class='line' id='LC9'><span class="nb">cd</span> <span class="nv">$1</span></div><div class='line' id='LC10'>git checkout <span class="nv">$2</span></div><div class='line' id='LC11'><span class="c">#we kill the .git because we want this repo just as starter and init our own repository (instead of export)</span></div><div class='line' id='LC12'>rm -rf .git</div><div class='line' id='LC13'><br/></div><div class='line' id='LC14'><span class="c">#set permissions for install</span></div><div class='line' id='LC15'>chmod 0777 assets assets/*</div><div class='line' id='LC16'>chmod 0666 .htaccess mysite/_config.php assets/*/*</div><div class='line' id='LC17'><br/></div><div class='line' id='LC18'>git init</div><div class='line' id='LC19'><br/></div><div class='line' id='LC20'>git submodule add git@github.com:silverstripe/silverstripe-cms.git cms</div><div class='line' id='LC21'><span class="nb">cd </span>cms</div><div class='line' id='LC22'>git checkout <span class="nv">$2</span></div><div class='line' id='LC23'><span class="nb">cd</span> ..</div><div class='line' id='LC24'>git add cms</div><div class='line' id='LC25'>git commit -m <span class="s2">&quot;checked out submodule cms to $2&quot;</span></div><div class='line' id='LC26'><br/></div><div class='line' id='LC27'>git submodule add git@github.com:silverstripe/sapphire.git sapphire</div><div class='line' id='LC28'><span class="nb">cd </span>sapphire</div><div class='line' id='LC29'>git checkout <span class="nv">$2</span></div><div class='line' id='LC30'><span class="nb">cd</span> ..</div><div class='line' id='LC31'>git add sapphire</div><div class='line' id='LC32'>git commit -m <span class="s2">&quot;checked out submodule sapphire to $2&quot;</span></div><div class='line' id='LC33'><br/></div><div class='line' id='LC34'><span class="c"># add common modules</span></div><div class='line' id='LC35'>git submodule add git://github.com/unclecheese/Uploadify.git uploadify</div><div class='line' id='LC36'>git submodule add git://github.com/unclecheese/DataObjectManager.git dataobject_manager</div><div class='line' id='LC37'>git submodule add git://github.com/silverstripe/silverstripe-userforms.git userform</div><div class='line' id='LC38'><br/></div><div class='line' id='LC39'>git submodule init</div><div class='line' id='LC40'>git submodule update</div><div class='line' id='LC41'><br/></div><div class='line' id='LC42'>git add .</div><div class='line' id='LC43'>git commit -m <span class="s2">&quot;Initial Commit&quot;</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1768946/a9878317a52800cee895671270530714013192f5/install_silverstripe.sh" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1768946#file_install_silverstripe.sh" style="float:right;margin-right:10px;color:#666">install_silverstripe.sh</a>
            <a href="https://gist.github.com/1768946">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>
</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.nerdpress.org/2012/02/09/silverstripe-setup-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

