<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>.htaccess URL rewrite</title>
		<link>http://www.allegro.cc/forums/view/595252</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 09 Mar 2008 00:27:43 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hello everyone!</p><p>I have a small issue with URL rewriting in .htaccess. Not that anything is not working, its just the issue with the size of the whole thing. </p><p>Here is a sample from my file:
</p><pre>
RewriteEngine On

RewriteRule ^/news/([0-9]+)/$ /news.php?news_id=$1
RewriteRule ^/article/([0-9]+)/$ /article.php?art_id=$1
RewriteRule ^/user/([0-9]+)/$ /show_user.php?user_id=$1
RewriteRule ^/login/$ /login.php
...
</pre><p>

See? It gets awfully long. What can I do here? Is there anything I can do? I thought of a unified URL structure like NEWS/ACTION/ID so its like news/delete/23 or news/edit/35 but that doesn&#39;t work for all of the stuff.</p><p>So, is there anything I can do? Or am I cursed to editing the file every time I add or change something?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Mon, 25 Feb 2008 01:53:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>RewriteRule ^(.*) index.php?q=$1 [L,QSA]
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Mon, 25 Feb 2008 01:58:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>OK, this opens up a new problem though, how do I parse the input? Something like this:</p><p>index.php?q=/news/edit/45/monkey/5/blah/10</p><p>So, the first parameter would always be the file ( news.php ), the second would be the name of a parameter and then the value, the next the name and then the value etc.</p><p>So the upper URL would be:</p><p>news.php?edit=45&amp;monkey=5&amp;blah=10</p><p>Correct?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Mon, 25 Feb 2008 02:06:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I got this from CakePHP:</p><div class="source-code snippet"><div class="inner"><pre>RewriteEngine on
RewriteRule ^$ engine<span class="k3">/</span>index.php <span class="k2">[</span>L<span class="k2">]</span>
<span class="p"># Translate path into the webroot if not already done</span>
RewriteRule <span class="k3">!</span>app<span class="k3">/</span>webroot<span class="k3">/</span> <span class="k3">-</span> <span class="k2">[</span>C<span class="k2">]</span>
RewriteRule <span class="k2">(</span>.<span class="k3">*</span><span class="k2">)</span> app<span class="k3">/</span>webroot<span class="k3">/</span>$<span class="n">1</span>
<span class="p"># If file doesn't exist in webroot then use Cx</span>
RewriteCond %<span class="k2">{</span>REQUEST_FILENAME<span class="k2">}</span> <span class="k3">!</span><span class="k3">-</span>f
RewriteCond %<span class="k2">{</span>REQUEST_FILENAME<span class="k2">}</span> <span class="k3">!</span><span class="k3">-</span>d
RewriteRule .<span class="k3">*</span> engine<span class="k3">/</span>index.php
</pre></div></div><p>

This is cool. It works like this: you have a website at <a href="http://www.contoso.com/mysite/">http://www.contoso.com/mysite/</a>. On the server, mysite/app/webroot is the folder where you put things like static HTML pages, CSS files, whatever, and mysite/engine is where CakePHP lives. When a user requests <a href="http://www.contoso.com/mysite/style.css">http://www.contoso.com/mysite/style.css</a>, the RewriteRules check mysite/app/webroot/style.css. If it exists, it serves that file. If it doesn&#39;t, the rules instead run mysite/engine/index.php, which uses $_SERVER[&quot;REQUEST_URI&quot;] to get the name of the requested file (so, if you request <a href="http://www.contoso.com/mysite/news/delete/27">http://www.contoso.com/mysite/news/delete/27</a>, it will look like &quot;mysite/app/webroot/news/delete/27&quot;, and you can just remove everything up to &quot;app/webroot&quot;).</p><p>This method is better than X-G&#39;s because the query string isn&#39;t affected by the rules, and because it allows static documents to co-exist.</p><p>[append]</p><p>You parse the output by exploding your request (<tt>explode(&quot;/&quot;, $request)</tt>), and then parsing the resulting array (array(&quot;news&quot;, &quot;edit&quot;, &quot;45&quot;, &quot;monkey&quot;, &quot;5&quot;, &quot;blah&quot;, &quot;10&quot;)). If you&#39;re using CakePHP or CodeIgniter or something similar, then you have code like this:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">class</span> controller_news
<span class="k2">{</span>
    function edit<span class="k2">(</span>$id<span class="k2">)</span>
    <span class="k2">{</span>
        <span class="c">// news/edit/45 calls this method with $id = 45.</span>
        <span class="c">// You can get all the parameters passed like this:</span>
        $args <span class="k3">=</span> func_get_args<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
        var_export<span class="k2">(</span>$args<span class="k2">)</span><span class="k2">;</span>
        <span class="c">// Prints: array("45", "monkey", "5", "blah", "10")</span>
    <span class="k2">}</span>
<span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Mon, 25 Feb 2008 02:10:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>In one project, I was just passing everything to a file like X-G said, checking a set directory to see if the file existed, if it did I served it up, if not I checked for plugins/pages before 404ing.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Mon, 25 Feb 2008 02:24:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You should see the stuff I setup for the wiki:</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td>RewriteEngine on</td></tr><tr><td class="number">2</td><td>&#160;</td></tr><tr><td class="number">3</td><td>RewriteCond %<span class="k2">{</span>REQUEST_URI<span class="k2">}</span> ^<span class="k3">/</span>bin<span class="k3">/</span>view<span class="k3">/</span>.<span class="k3">+</span></td></tr><tr><td class="number">4</td><td>RewriteRule ^<span class="k3">/</span>bin<span class="k3">/</span>view<span class="k3">/</span><span class="k2">[</span>^<span class="k3">/</span><span class="k2">]</span><span class="k3">+</span><span class="k3">/</span><span class="k2">(</span>.<span class="k3">*</span><span class="k2">)</span> <span class="k3">/</span>$<span class="n">1</span> <span class="k2">[</span>R<span class="k2">]</span></td></tr><tr><td class="number">5</td><td>&#160;</td></tr><tr><td class="number">6</td><td>RewriteCond %<span class="k2">{</span>REQUEST_URI<span class="k2">}</span> ^<span class="k3">/</span>bin<span class="k3">/</span>view<span class="k3">/</span>.<span class="k3">+</span></td></tr><tr><td class="number">7</td><td>RewriteRule ^<span class="k3">/</span>bin<span class="k3">/</span>view<span class="k3">/</span><span class="k2">[</span>^<span class="k3">/</span><span class="k2">]</span><span class="k3">+</span> <span class="k3">/</span> <span class="k2">[</span>R<span class="k2">]</span></td></tr><tr><td class="number">8</td><td>&#160;</td></tr><tr><td class="number">9</td><td>RewriteCond %<span class="k2">{</span>REQUEST_URI<span class="k2">}</span> ^<span class="k3">/</span>bin<span class="k3">/</span>view$</td></tr><tr><td class="number">10</td><td>RewriteRule ^<span class="k3">/</span>bin<span class="k3">/</span>view$ <span class="k3">/</span> <span class="k2">[</span>R<span class="k2">]</span></td></tr><tr><td class="number">11</td><td>&#160;</td></tr><tr><td class="number">12</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> Ask\ Jeeves<span class="k3">/</span>Teoma <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">13</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> VoilaBot <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">14</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> BecomeBot <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">15</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> Exabot <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">16</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> Googlebot <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">17</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> Yahoo<span class="k3">!</span>\ Slurp <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">18</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> Google\ Desktop <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">19</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> MQBOT<span class="k3">/</span>Nutch <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">20</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> msnbot <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">21</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> YahooSeeker <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">22</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> OutfoxBot <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">23</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> FreshCrawler <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">24</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> robot <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">25</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> spider <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">26</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> Twisted\ PageGetter <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">27</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> yacybot <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">28</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> yacy <span class="k2">[</span>OR<span class="k2">]</span></td></tr><tr><td class="number">29</td><td>RewriteCond %<span class="k2">{</span>HTTP_USER_AGENT<span class="k2">}</span> Yahoo-MMCrawler</td></tr><tr><td class="number">30</td><td>RewriteRule ^<span class="k2">(</span>.<span class="k3">*</span><span class="k2">)</span> $<span class="n">1</span>?useskin<span class="k3">=</span>simple <span class="k2">[</span>C,QSA<span class="k2">]</span></td></tr><tr><td class="number">31</td><td>&#160;</td></tr><tr><td class="number">32</td><td><span class="p"># Verifying if user forgot to put trailling slash. If so, we'll rewrite to Main_Page</span></td></tr><tr><td class="number">33</td><td>RewriteCond %<span class="k2">{</span>REQUEST_URI<span class="k2">}</span> ^<span class="k3">/</span>?$</td></tr><tr><td class="number">34</td><td>RewriteRule ^<span class="k3">/</span>?$ <span class="k3">/</span>index.php<span class="k3">/</span>Main_Page <span class="k2">[</span>L<span class="k2">]</span></td></tr><tr><td class="number">35</td><td>&#160;</td></tr><tr><td class="number">36</td><td><span class="p"># rewrite Actions</span></td></tr><tr><td class="number">37</td><td><span class="p">#  'edit', 'watch', 'unwatch', 'delete','revert', 'rollback', 'protect',</span></td></tr><tr><td class="number">38</td><td><span class="p">#  'unprotect','info','markpatrolled','validate','render','deletetrackback','print',</span></td></tr><tr><td class="number">39</td><td><span class="p">#  'dublincore','creativecommons','credits','submit','viewsource','history','raw', 'purge'</span></td></tr><tr><td class="number">40</td><td>RewriteCond %<span class="k2">{</span>REQUEST_URI<span class="k2">}</span> ^<span class="k3">/</span><span class="k2">(</span>purge<span class="k3">|</span>edit<span class="k3">|</span>watch<span class="k3">|</span>unwatch<span class="k3">|</span><span class="k1">delete</span><span class="k3">|</span>revert<span class="k3">|</span>rollback<span class="k3">|</span>protect<span class="k3">|</span>unprotect<span class="k3">|</span>info<span class="k3">|</span>markpatrolled<span class="k3">|</span>validate<span class="k3">|</span>render<span class="k3">|</span>deletetrackback<span class="k3">|</span>print<span class="k3">|</span>dublincore<span class="k3">|</span>creativecommons<span class="k3">|</span>credits<span class="k3">|</span>submit<span class="k3">|</span>viewsource<span class="k3">|</span>history<span class="k3">|</span>raw<span class="k3">|</span>purge<span class="k2">)</span><span class="k3">/</span></td></tr><tr><td class="number">41</td><td>RewriteRule ^<span class="k3">/</span><span class="k2">(</span>purge<span class="k3">|</span>edit<span class="k3">|</span>watch<span class="k3">|</span>unwatch<span class="k3">|</span><span class="k1">delete</span><span class="k3">|</span>revert<span class="k3">|</span>rollback<span class="k3">|</span>protect<span class="k3">|</span>unprotect<span class="k3">|</span>info<span class="k3">|</span>markpatrolled<span class="k3">|</span>validate<span class="k3">|</span>render<span class="k3">|</span>deletetrackback<span class="k3">|</span>print<span class="k3">|</span>dublincore<span class="k3">|</span>creativecommons<span class="k3">|</span>credits<span class="k3">|</span>submit<span class="k3">|</span>viewsource<span class="k3">|</span>history<span class="k3">|</span>raw<span class="k3">|</span>purge<span class="k2">)</span><span class="k3">/</span><span class="k2">(</span>.<span class="k3">+</span><span class="k2">)</span> <span class="k3">/</span>index.php<span class="k3">/</span>$<span class="n">2</span>?action<span class="k3">=</span>$<span class="n">1</span> <span class="k2">[</span>L,QSA<span class="k2">]</span></td></tr><tr><td class="number">42</td><td>&#160;</td></tr><tr><td class="number">43</td><td><span class="p"># Don't rewrite requests for files in MediaWiki subdirectories,</span></td></tr><tr><td class="number">44</td><td><span class="p"># MediaWiki PHP files, HTTP error documents, favicon.ico, or robots.txt</span></td></tr><tr><td class="number">45</td><td><span class="p">#RewriteCond %{REQUEST_URI} !^/(stylesheets|pub|config|stats|skins|bin|languages|locale|math|images)/</span></td></tr><tr><td class="number">46</td><td><span class="p">#RewriteCond %{REQUEST_URI} !^/.+.php</span></td></tr><tr><td class="number">47</td><td>RewriteCond %<span class="k2">{</span>REQUEST_URI<span class="k2">}</span> <span class="k3">!</span>^<span class="k3">/</span>error<span class="k3">/</span><span class="k2">(</span><span class="n">40</span><span class="k2">(</span><span class="n">1</span><span class="k3">|</span><span class="n">3</span><span class="k3">|</span><span class="n">4</span><span class="k2">)</span><span class="k3">|</span><span class="n">500</span><span class="k2">)</span>.html</td></tr><tr><td class="number">48</td><td>RewriteCond %<span class="k2">{</span>REQUEST_URI<span class="k2">}</span> <span class="k3">!</span>^<span class="k3">/</span>favicon.ico</td></tr><tr><td class="number">49</td><td>RewriteCond %<span class="k2">{</span>REQUEST_URI<span class="k2">}</span> <span class="k3">!</span>^<span class="k3">/</span>robots.txt</td></tr><tr><td class="number">50</td><td>&#160;</td></tr><tr><td class="number">51</td><td>&#160;</td></tr><tr><td class="number">52</td><td><span class="p"># Do main rewrite</span></td></tr><tr><td class="number">53</td><td>RewriteCond <span class="k3">/</span>var<span class="k3">/</span>www<span class="k3">/</span>%<span class="k2">{</span>REQUEST_FILENAME<span class="k2">}</span> <span class="k3">!</span><span class="k3">-</span>f</td></tr><tr><td class="number">54</td><td>RewriteCond <span class="k3">/</span>var<span class="k3">/</span>www<span class="k3">/</span>%<span class="k2">{</span>REQUEST_FILENAME<span class="k2">}</span> <span class="k3">!</span><span class="k3">-</span>d</td></tr><tr><td class="number">55</td><td>RewriteCond %<span class="k2">{</span>REQUEST_URI<span class="k2">}</span> <span class="k3">!</span>^<span class="k3">/</span><span class="k2">(</span>stylesheets<span class="k3">|</span>pub<span class="k3">|</span>config<span class="k3">|</span>stats<span class="k3">|</span>skins<span class="k3">|</span>bin<span class="k3">|</span>languages<span class="k3">|</span>locale<span class="k3">|</span>math<span class="k3">|</span>images<span class="k3">|</span>history<span class="k3">|</span>icons<span class="k2">)</span><span class="k3">/</span></td></tr><tr><td class="number">56</td><td>RewriteCond %<span class="k2">{</span>REQUEST_URI<span class="k2">}</span> <span class="k3">!</span>^<span class="k3">/</span><span class="k2">(</span>stylesheets<span class="k3">|</span>pub<span class="k3">|</span>config<span class="k3">|</span>stats<span class="k3">|</span>skins<span class="k3">|</span>bin<span class="k3">|</span>languages<span class="k3">|</span>locale<span class="k3">|</span>math<span class="k3">|</span>images<span class="k3">|</span>history<span class="k3">|</span>icons<span class="k2">)</span>$</td></tr><tr><td class="number">57</td><td>RewriteCond %<span class="k2">{</span>REQUEST_URI<span class="k2">}</span> <span class="k3">!</span>^<span class="k3">/</span>.<span class="k3">+</span>\.php</td></tr><tr><td class="number">58</td><td>RewriteCond %<span class="k2">{</span>REQUEST_URI<span class="k2">}</span> <span class="k3">!</span>^<span class="k3">/</span>~.<span class="k3">*</span></td></tr><tr><td class="number">59</td><td>RewriteRule ^<span class="k2">(</span>.<span class="k3">*</span><span class="k2">)</span>$ <span class="k3">/</span>index.php$<span class="n">1</span> <span class="k2">[</span>L,QSA<span class="k2">]</span></td></tr></tbody></table></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 25 Feb 2008 02:31:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>RewriteCond %{REQUEST_FILENAME} !-f<br />RewriteCond %{REQUEST_FILENAME} !-d</p><p>Was also in the file. I just neglected to mention that. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Mon, 25 Feb 2008 02:48:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
<span class="source-code"><span class="p">#RewriteCond %{REQUEST_URI} !^/.+.php</span></span>
</p></div></div><p>Technically, &quot;!^.+\.php&quot; <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Mon, 25 Feb 2008 02:52:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Perhaps you&#39;d rather have <tt>news/edit/35</tt> be <tt>news/35/edit</tt>, which is hard to do (along with other similar style of URLs) unless you use a global dispatcher. </p><p>I use this for my CMS in the <tt>/var/www/cms/site</tt> directory:
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
RewriteEngine on<br />RewriteCond %{REQUEST_FILENAME} !-f<br />RewriteRule ^(.*)$ /.dispatcher.php [QSA,L]
</p></div></div><p>

The document root directory is: <tt>/var/www/cms/site/domainname.com/web</tt>. I then use an alias in each vhost to point /.dispatcher.php to <tt>/var/www/cms/site/dispatcher.php</tt>.</p><p>That single file just looks at the domain name, loads the configuration file for it, loops through each module that implements IRequestHandler, and lets them determine who gets to serve the request. (First come, first serve.)</p><p>It&#39;s beautiful because URLs can be anything and every site can share the same exact PHP module code. </p><p>Each module can implement any URL how it sees fit. So the news module could see <tt>/news/2008/01/01/newyear</tt> and decide to handle the request by loading up the news item and calling <tt>$tpl-&gt;display(&#39;News/view&#39;)</tt> which would first load up the website&#39;s specific news template.</p><p>The CMS module can look at URLs in a database and display HTML as entered via a WYSIWYG online editor. And anything in the <tt>/var/www/cms/site/domainname.com/template</tt> directory automatically gets viewed as a last resort (if the name matches the URL) so you can easily add one-off pages per each site.</p><p>Those are just examples of a couple modules; there are plenty of ways to do this. The key thing is, though, that &quot;one PHP file per page&quot; based websites are not good.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Mon, 25 Feb 2008 03:19:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ll think about the modules idea. I think its a pretty good idea. But I only have one site, so isn&#39;t it kinda pointless?</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Those are just examples of a couple modules; there are plenty of ways to do this. The key thing is, though, that &quot;one PHP file per page&quot; based websites are not good.
</p></div></div><p>

Hmm... I am getting something wrong here. Don&#39;t you do &quot;one file per page&quot; anyway? Isn&#39;t the difference in the fact that you hide it?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Mon, 25 Feb 2008 03:42:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You&#39;re right that it is a lot of overhead if never reused. But one site becomes two sites ... and so on until you are sick of writing the same stuff over and over again. </p><p>And no, my approach is far from page based. The entire module sits inside of a class. For instance, a &quot;pretend&quot; module:</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="k3">&lt;</span>?php</td></tr><tr><td class="number">2</td><td>  <span class="k1">class</span> Module_News extends Module implements IRequestHandler</td></tr><tr><td class="number">3</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">4</td><td>    <span class="k1">public</span> function handleGetRequest<span class="k2">(</span>HTTPRequest $req<span class="k2">)</span></td></tr><tr><td class="number">5</td><td>    <span class="k2">{</span></td></tr><tr><td class="number">6</td><td>      <span class="c">// /news/view/$id </span></td></tr><tr><td class="number">7</td><td>      <span class="k1">if</span> <span class="k2">(</span>$req-&gt;path<span class="k2">[</span><span class="n">0</span><span class="k2">]</span> <span class="k3">!</span><span class="k3">=</span> <span class="s">'news'</span><span class="k2">)</span> <span class="k1">return</span> FALSE<span class="k2">;</span> <span class="c">// doesn't handle the url</span></td></tr><tr><td class="number">8</td><td>&#160;</td></tr><tr><td class="number">9</td><td>      <span class="k1">switch</span> <span class="k2">(</span>$req-&gt;path<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">)</span></td></tr><tr><td class="number">10</td><td>      <span class="k2">{</span></td></tr><tr><td class="number">11</td><td>        <span class="k1">case</span> <span class="s">'view'</span><span class="k2">:</span></td></tr><tr><td class="number">12</td><td>          $tpl-&gt;news <span class="k3">=</span> DBO_News::find<span class="k2">(</span>$req-&gt;path<span class="k2">[</span><span class="n">2</span><span class="k2">]</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">13</td><td>          $tpl-&gt;display<span class="k2">(</span><span class="s">'news/view'</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">14</td><td>          <span class="k1">return</span> TRUE<span class="k2">;</span></td></tr><tr><td class="number">15</td><td>&#160;</td></tr><tr><td class="number">16</td><td>        <span class="k1">case</span> <span class="s">'foo'</span><span class="k2">:</span> <span class="c">// other logic, etc</span></td></tr><tr><td class="number">17</td><td>      <span class="k2">}</span></td></tr><tr><td class="number">18</td><td>&#160;</td></tr><tr><td class="number">19</td><td>      <span class="k1">return</span> FALSE<span class="k2">;</span></td></tr><tr><td class="number">20</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">21</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">22</td><td>?<span class="k3">&gt;</span></td></tr></tbody></table></div></div><p>

All of the logic goes inside the class. That&#39;s the stuff you don&#39;t ever want to rewrite. If I have a second website that needs something a little bit different, I first try to add the functionality via configuration. If that fails to be practical, I just extend the class module and use it for that particular website.</p><p>The template stuff is per page, but that&#39;s fine. The basic news &quot;view&quot; template might look like:</p><div class="source-code snippet"><div class="inner"><pre><span class="k3">&lt;</span>mef:template container<span class="k3">=</span><span class="s">"default"</span><span class="k3">&gt;</span>
  <span class="k3">&lt;</span>html&gt;
    <span class="k3">&lt;</span>h1&gt;<span class="k2">{</span>news.title<span class="k2">}</span><span class="k3">&lt;</span><span class="k3">/</span>h1&gt;
    <span class="k3">&lt;</span>div&gt;<span class="k2">{</span>news.body<span class="k2">}</span><span class="k3">&lt;</span><span class="k3">/</span>div&gt;
  <span class="k3">&lt;</span><span class="k3">/</span>html&gt;
<span class="k3">&lt;</span><span class="k3">/</span>mef:template&gt;
</pre></div></div><p>

Then for a particular website, I&#39;ll probably end up copy/pasting it into the website&#39;s local template directory and editing it to look like however I want. </p><p>The key is that I can easily build a new website without having to write a line of duplicated PHP. I expect to write custom template files ... that&#39;s what makes web sites unique. But the &quot;business logic&quot;? It&#39;s mostly reusable.</p><p>This is my approach that works great for me, and you may find something you like better. But never resort to spaghetti PHP code. It&#39;s never worth it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Mon, 25 Feb 2008 04:03:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Now I get it. So, this is just theoretical, you have modules in a directory, like <i>modules</i> and when someone requests the page the request is send to index.php or whatever the main file is. </p><p>Then the <i>modules</i> directory ( or database, don&#39;t really know ) is scanned for modules. And since every module is derived from Module you can just do:</p><div class="source-code snippet"><div class="inner"><pre>$request <span class="k3">=</span> <span class="k1">new</span> IRequest<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
$request-&gt;page <span class="k3">=</span> ...<span class="k2">;</span>

<span class="k1">while</span><span class="k2">(</span><span class="k3">!</span>EndOfModules<span class="k2">(</span><span class="k2">)</span><span class="k2">)</span>
<span class="k2">{</span>
    $module <span class="k3">=</span> <span class="k1">new</span> Module<span class="k2">(</span>$data<span class="k2">[</span><span class="s">"module_name"</span><span class="k2">]</span><span class="k2">)</span><span class="k2">;</span>
    $module-&gt;handleGet<span class="k2">(</span>$request<span class="k2">)</span><span class="k2">;</span>
    
<span class="k2">}</span>
</pre></div></div><p>

Wow, even if this is not exactly what you use, its pretty darn good. This way you can easily add way more modules without any hassle. No hard-coding... Real flexible. Hehe I&#39;m all excited now! <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /></p><p>Just one more thing, how do you handle where the stuff gets displayed. The website has a certain structure. Header, footer, navbar etc. How do you know where each module will go? It could have a $type member var in it... Or is there a better way to handle this?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Mon, 25 Feb 2008 04:22:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I have an ini file per website (domain) that says which modules to load:
</p><pre>
[modules]
News=true
AutoTemplate=true
</pre><p>
Those are looped through and added to a modules array within the base Application class.</p><p>I have a function called something like <tt>Application::callInterface(&#39;IRequestHandler&#39;, &#39;handleRequest&#39;, $args)</tt> and that is responsible for looping through each module, calling &#39;handleRequest&#39; until one of them returns TRUE. It&#39;s been a while since I&#39;ve looked at my base classes, so I don&#39;t remember exactly what I&#39;m doing.</p><p>Regarding your second question, I&#39;m not sure exactly what you are talking about. But I use &quot;containers.&quot; One might look like:</p><div class="source-code snippet"><div class="inner"><pre><span class="k3">&lt;</span>html&gt;
<span class="k3">&lt;</span>head&gt;<span class="k3">&lt;</span>title&gt;Default Container<span class="k3">&lt;</span><span class="k3">/</span>title&gt;<span class="k3">&lt;</span><span class="k3">/</span>head&gt;
<span class="k3">&lt;</span>body&gt;
 
<span class="k2">{</span>html<span class="k2">}</span> 

<span class="k3">&lt;</span><span class="k3">/</span>body&gt;
<span class="k3">&lt;</span><span class="k3">/</span>html&gt;
</pre></div></div><p>

The {html} correlates to the &lt;html&gt; field in the template file. Same goes with any other field you want to pass as a tag or as a parameter (in the <tt>&lt;mef:container /&gt;</tt> tag).</p><p>Also note that templates can also pull in data as long as a recognized object is used.
</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// loop through recent threads</span>
<span class="k3">&lt;</span>mef:loop collection<span class="k3">=</span><span class="s">"news.recent(count: 5)"</span> item<span class="k3">=</span><span class="s">"n"</span><span class="k3">&gt;</span>
  <span class="k2">{</span>n.title<span class="k2">}</span>
<span class="k3">&lt;</span><span class="k3">/</span>mef:loop&gt;
</pre></div></div><p>
For instance, that would call <tt>DAO_News::recent()</tt> inline. (The DAO class of objects are just read-only interfaces from a template to the more general purpose DBOs.)</p><p>That allows templates files to do more than what they might originally have been intended to do by the module writer. (e.g., maybe on your News/View template page you also want to show something from a different module.)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Mon, 25 Feb 2008 04:31:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Seems pretty logical. But, there is one line I do not understand as I do not have so much experience in the OOP world:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">class</span> Foo extends Bar implements Baz
</pre></div></div><p>

So, what does this mean? That Bar implements Baz and that Foo extends Bar? That would mean that Baz is an abstract class and that Bar implements it and Foo extends the implemented class Bar?</p><p>Regarding the HTML thing, I think there was a misunderstanding. I maybe just talking garbage but anyway. Allegro.cc has two sidebars and the center where the content is. Now, I am speculating, but I reckon that the sidebars are constant ie. are not tied to modules? You know what I mean? Sure, the content is tied to a module, but what about the sidebars etc.? Guess theres not much need for that anyway... Just asking.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Mon, 25 Feb 2008 04:49:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Baz is an interface, so class Foo inherits from Bar and implements everything required by the Baz interface.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Mon, 25 Feb 2008 04:53:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>OK, I thought it was something like that. Thanks for destroying my doubts. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Mon, 25 Feb 2008 04:56:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Looking at the PHP code Matthew posted, does PHP really look almost like Java these days?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Fladimir da Gorf)</author>
		<pubDate>Mon, 25 Feb 2008 05:37:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Looking at the PHP code Matthew posted, does PHP really look almost like Java these days?
</p></div></div><p>Yes. A horrible mix of Perl and Java. I still wonder why people like it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 25 Feb 2008 05:39:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Don&#39;t make me laugh! Even PHP at its worst isn&#39;t nearly as bad as perl! Yuck! <img src="http://www.allegro.cc/forums/smileys/lipsrsealed.gif" alt=":-X" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Mon, 25 Feb 2008 05:47:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Good PHP isn&#39;t bad. Bad PHP is horrible. <b>cough*zencart*cough</b>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Mon, 25 Feb 2008 06:00:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Don&#39;t make me laugh! Even PHP at its worst isn&#39;t nearly as bad as perl! Yuck! <img src="http://www.allegro.cc/forums/smileys/lipsrsealed.gif" alt=":-X" />
</p></div></div><p>You obviously haven&#39;t seen actual live PHP applications then. Right now I&#39;m doing a small job working with ZenCart, if you feel like going out of your mind, take a look at all the template files. Almost every PHP program I&#39;ve ever seen is made the same way.</p><p>However, my Perl programs are much much cleaner.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 25 Feb 2008 06:02:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Look at it this way, PHP is the most popular scripting language currently. So naturally there will be more people that write ugly code. Its also very simple, contributing to people writing said bad code. </p><p>Perl is scary, thats why beginners don&#39;t use it*. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /> But PHP code can be very clean, readable and efficient if written in the right way. Works for any language.</p><p><sub>
* At least not as much as PHP IMHO.
</sub>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Mon, 25 Feb 2008 06:06:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>PHP is pretty fast and has an enormous amount of junk that makes web development easy.  That junk is really invaluable.</p><p><i>(more on other bad coders coding in php)</i>: You shouldn&#39;t judge your language choices by the stupidity of other coders.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Mon, 25 Feb 2008 06:08:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Look at it this way, PHP is the most popular scripting language currently. So naturally there will be more people that write ugly code
</p></div></div><p>Clueless much? There area actually still more <i>usefull</i> sites that run perl than PHP. Well known fact, php was once implemented with Perl.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Perl is scary, thats why beginners don&#39;t use it. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div></div><p>Its the same syntax as php! Except theres three separate special datatypes and BUILT IN regexes. I don&#39;t see much of a difference.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
But PHP code can be very clean, readable and efficient if written in the right way.
</p></div></div><p>Oh sure, apply that to your precious php, and not perl? <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><p>Perl was my first programming language. Taught it to myself by reading a book and playing with scripts. If <i>I</i> can do it, anyone can.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
PHP is pretty fast and has an enormous amount of junk that makes web development easy. That junk is really invaluable.
</p></div></div><p>Junk is indeed the right term. And it dumps it all in the global namespace. hundreds of functions you&#39;re likely to not use in most apps!<br /> 
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
(more on other bad coders coding in php): You shouldn&#39;t judge your language choices by the stupidity of other coders.
</p></div></div><p>Except when most of the apps are coded in that way, then its more of a language issue. PHP was created to write spagetty &lt;?php code ?&gt; crap.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 25 Feb 2008 06:10:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If you want to learn how not to write something, look at Zencart.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Mon, 25 Feb 2008 06:14:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Thomas said:</div><div class="quote"><p>

Well known fact, php was once implemented with Perl.
</p></div></div><p>
Not that it&#39;s related, but hasn&#39;t php been implemented in a lot of language?</p><div class="quote_container"><div class="title">Thomas said:</div><div class="quote"><p>

Except when most of the apps are coded in that way, then its more of a language issue.
</p></div></div><p>
<img src="http://www.allegro.cc/forums/smileys/lipsrsealed.gif" alt=":-X" /> You can&#39;t actually think that...  Whats the point of a language but to aide you in some purpose?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Mon, 25 Feb 2008 06:15:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Not that it&#39;s related, but hasn&#39;t php been implemented in a lot of language?
</p></div></div><p>It started out as a Perl program, and is now written in C afaik. From the state of PHP code itself, I can only imagine what php&#39;s C code looks like <img src="http://www.allegro.cc/forums/smileys/cry.gif" alt=":&#39;(" /></p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
<img src="http://www.allegro.cc/forums/smileys/lipsrsealed.gif" alt=":-X" /> You can&#39;t actually think that... Whats the point of a language but to aide you in some purpose?
</p></div></div><p>Ok, then it must be the other option, MOST php coders are completely worthless. Then again if it is that, then PHP attracts MOSTLY worthless coders, which doesn&#39;t put php in a good light.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 25 Feb 2008 06:17:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Clueless much? There area actually still more usefull sites that run perl than PHP. Well known fact, php was once implemented with Perl.
</p></div></div><p>

If George Bush and Vladimir Putin prefer some Zango Cola over Coca-Cola then that does not mean that Coca-Cola is any less popular... </p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Oh sure, apply that to your precious php, and not perl?
</p></div></div><p>

Sure it applies to Perl, but you started the debate.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Perl was my first programming language. Taught it to myself by reading a book and playing with scripts. If I can do it, anyone can.
</p></div></div><p>

Same here man, just replace Perl with PHP. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Junk is indeed the right term. And it dumps it all in the global namespace. hundreds of functions you&#39;re likely to not use in most apps!
</p></div></div><p>

Yeah it has its quirks, but PHP 6 will fix that AFAIK. </p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Except when most of the apps are coded in that way, then its more of a language issue. PHP was created to write spagetty &lt;?php code ?&gt; crap.
</p></div></div><p>

Popularity applies here... 90% of the code is bad because 90% of the users are beginners that don&#39;t have a clue. Its not a language issue... Anymore. Granted, it was some time ago... <b>cough</b> register globals <b>cough</b></p><p>EDIT:</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
It started out as a Perl program, ...
</p></div></div><p>

No:
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
PHP was written as a set of Common Gateway Interface (CGI) binaries in the C programming language by the Danish/Greenlandic programmer Rasmus Lerdorf in 1994, to replace a small set of Perl scripts he had been using to maintain his personal homepage.
</p></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Mon, 25 Feb 2008 06:20:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Popularity applies here... 90% of the code is bad because 90% of the users are beginners that don&#39;t have a clue. Its not a language issue... Anymore. Granted, it was some time ago... <b>cough</b> register globals <b>cough</b>
</p></div></div><p>Take any popular php app and prove to me that its not crap code wise. Dare you.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
PHP was written as a set of Common Gateway Interface (CGI) binaries in the C programming language by the Danish/Greenlandic programmer Rasmus Lerdorf in 1994, to replace a small set of Perl scripts he had been using to maintain his personal homepage.
</p></div></div><p>I just said that. It started out as a perl program/script, and was then rewritten in C.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 25 Feb 2008 06:23:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah but technically, the Perl scripts weren&#39;t PHP! They were PHP after they were rewritten!</p><p>Anyway, phpBB 3?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Mon, 25 Feb 2008 06:25:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Yeah but technically, the Perl scripts weren&#39;t PHP! They were PHP after they were rewritten!
</p></div></div><p>This is only an asumption, but I&#39;m betting his original site loaded and executed Php like template files with embeded Perl code, which explains PHP&#39;s similarity to Perl.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Anyway, phpBB 3?
</p></div></div><p>phpBB? At least v3 seems to be using a templating system of sorts (custom format using html comments? huh?). Being brand new, I know little about it. But if its anything like the prior phpBB&#39;s, its pure crap.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 25 Feb 2008 06:31:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
phpBB? At least v3 seems to be using a templating system of sorts (custom format using html comments? huh?). Being brand new, I know little about it. But if its anything like the prior phpBB&#39;s, its pure crap.
</p></div></div><p>

OK Thomas, your turn! You show me some popular application written in Perl thats not crap! <img src="http://www.allegro.cc/forums/smileys/cool.gif" alt="8-)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Mon, 25 Feb 2008 06:32:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Any popular application is likely pure crap. Thats why I use custom code for the most part. <img src="http://www.allegro.cc/forums/smileys/cool.gif" alt="8-)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Mon, 25 Feb 2008 06:34:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ever heard of slashcode? How &#39;bout apt?</p><div class="quote_container"><div class="title">wp said:</div><div class="quote"><p>
Large projects written in Perl include Slash, Bugzilla, TWiki and Movable Type. Many high-traffic websites, such as bbc.co.uk, Amazon.com, LiveJournal.com, Ticketmaster.com and IMDb.com[16] use Perl extensively.
</p></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 25 Feb 2008 06:34:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Those high traffic websites aren&#39;t popular <i>applications</i>. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /> A.cc uses PHP, and works just as well as those sites, just not on as large a scale.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Mon, 25 Feb 2008 06:35:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Many high-traffic websites, such as bbc.co.uk, Amazon.com, LiveJournal.com, Ticketmaster.com and IMDb.com[16] use Perl extensively.
</p></div></div><p>

Cheater! Those are not available to the public and the applications aren&#39;t popular but the websites are! Different!</p><p>Hence, I could say Allegro.cc, I dare you to say otherwise, Matthew will smite you! <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /><img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Mon, 25 Feb 2008 06:36:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Wow, you guys totally missed the first sentence. Try paying attention.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
A.cc uses PHP, and works just as well as those sites, just not on as large a scale.
</p></div></div><p>Scalability is part of usability.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 25 Feb 2008 06:37:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Perl said:</div><div class="quote"><p>

Large projects written in Perl include Slash, Bugzilla, TWiki and Movable Type.
</p></div></div><p>

</p><div class="quote_container"><div class="title">PHP said:</div><div class="quote"><p>

MediaWiki, Typo3, phpBB3, Drupal
</p></div></div><p>

apt is not a web application. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /> I thought we were talking about those. Anyways, time to go look at all the projects source code and vote which one has the dirtiest...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Mon, 25 Feb 2008 06:41:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Scalability is part of usability.
</p></div></div><p>

I didn&#39;t say it wasn&#39;t scalable. I just said it wasn&#39;t on as large a scale. The sites from WP likely run on quite a few servers, whereas a.cc runs on one.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Mon, 25 Feb 2008 06:42:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Intead of those apps, look at PHPBB2, ZenCart, and Moodle.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 25 Feb 2008 06:43:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><a href="http://avatraxiom.livejournal.com/58084.html">http://avatraxiom.livejournal.com/58084.html</a></p><p>Also, nobody ever claimed those apps were written well. What about Drupal or e107? There are many PHP apps that aren&#39;t coded badly. (Although I&#39;ve never looked at the source of those applications, I&#39;ve never heard anybody say anything bad about them).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Mon, 25 Feb 2008 06:46:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Dude Thomas, why are you so angry about PHP?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Mon, 25 Feb 2008 06:46:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>He has to deal with Zencart. I only looked at it for under an hour and that was almost enough to make me angry about PHP. Zencart&#39;s devs do have a place on my hated developers list, though.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Mon, 25 Feb 2008 06:47:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Dude Thomas, why are you so angry about PHP?
</p></div></div><p>I&#39;m more iritated about Vaneeto&#39;s (and many other people&#39;s random) Perl comments. But then I&#39;ve just spent 3 days trying to hack an old template into a new version of ZenCart. God my head hurts.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 25 Feb 2008 06:49:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Oh sure, sure, now I write random comments... I wonder what this is:</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Yes. A horrible mix of Perl and Java. I still wonder why people like it.
</p></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Mon, 25 Feb 2008 06:50:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Yes. A horrible mix of Perl and Java. I still wonder why people like it.
</p></div></div><p>You can mix one or more non horrible things and get a horrible result you know.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 25 Feb 2008 06:51:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Personally, my Perl comments are in return to PHP comments. I don&#39;t hate Perl. I don&#39;t like how the code looks, but I don&#39;t have enough experience with it to form a solid opinion.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Mon, 25 Feb 2008 06:51:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
You can mix one or more non horrible things and get a horrible result you know.
</p></div></div><p>

That was not the point. The point was that you were the first to make a random comment. I did not write random comments about Perl, one maybe, but all others were not random.</p><p>Well, at least not any less or more random then yours.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Mon, 25 Feb 2008 06:53:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I didn&#39;t necessarily mean yours was random, most people&#39;s are.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 25 Feb 2008 06:54:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, seeing as how we single handedly derailed this thread, I might as well give out cookies for the ones that helped! (with the problem at hand, <i>not</i> the derailing part <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Mon, 25 Feb 2008 07:00:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Regarding the HTML thing, I think there was a misunderstanding. I maybe just talking garbage but anyway. Allegro.cc has two sidebars and the center where the content is. Now, I am speculating, but I reckon that the sidebars are constant ie. are not tied to modules? You know what I mean? Sure, the content is tied to a module, but what about the sidebars etc.? Guess theres not much need for that anyway... Just asking.
</p></div></div><p>
A.cc isn&#39;t written on my complete CMS engine, but if it might look something like this if it weren&#39;t static:</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="c">// index.tpl</span></td></tr><tr><td class="number">2</td><td><span class="k3">&lt;</span>mef:template container<span class="k3">=</span><span class="s">"three-columns"</span><span class="k3">&gt;</span></td></tr><tr><td class="number">3</td><td>&#160;</td></tr><tr><td class="number">4</td><td>  <span class="k3">&lt;</span>html&gt;</td></tr><tr><td class="number">5</td><td>   <span class="k3">&lt;</span>ul&gt;</td></tr><tr><td class="number">6</td><td>    <span class="k3">&lt;</span>li mef:loop<span class="k3">=</span><span class="s">"n; news"</span><span class="k3">&gt;</span></td></tr><tr><td class="number">7</td><td>      <span class="k3">&lt;</span>h2&gt;<span class="k2">{</span>n.caption<span class="k3">&lt;</span><span class="k3">/</span>h2&gt;</td></tr><tr><td class="number">8</td><td>      <span class="k3">&lt;</span>div&gt;<span class="k2">{</span>n.body<span class="k2">}</span><span class="k3">&lt;</span><span class="k3">/</span>div&gt;</td></tr><tr><td class="number">9</td><td>    <span class="k3">&lt;</span><span class="k3">/</span>li&gt;</td></tr><tr><td class="number">10</td><td>   <span class="k3">&lt;</span><span class="k3">/</span>ul&gt;</td></tr><tr><td class="number">11</td><td>  <span class="k3">&lt;</span><span class="k3">/</span>html&gt;</td></tr><tr><td class="number">12</td><td>&#160;</td></tr><tr><td class="number">13</td><td>  <span class="k3">&lt;</span>leftcolumn&gt;</td></tr><tr><td class="number">14</td><td>    <span class="k3">&lt;</span>h2&gt;Allegro.cc<span class="k3">&lt;</span><span class="k3">/</span>h2&gt;</td></tr><tr><td class="number">15</td><td>    <span class="k3">&lt;</span>ul&gt;</td></tr><tr><td class="number">16</td><td>      <span class="k3">&lt;</span>li&gt;Depot<span class="k3">&lt;</span><span class="k3">/</span>li&gt;</td></tr><tr><td class="number">17</td><td>      <span class="k3">&lt;</span>li&gt;Forums<span class="k3">&lt;</span><span class="k3">/</span>li&gt;</td></tr><tr><td class="number">18</td><td>    <span class="k3">&lt;</span><span class="k3">/</span>ul&gt;</td></tr><tr><td class="number">19</td><td>  <span class="k3">&lt;</span><span class="k3">/</span>leftcolumn&gt;</td></tr><tr><td class="number">20</td><td>&#160;</td></tr><tr><td class="number">21</td><td><span class="k3">&lt;</span><span class="k3">/</span>mef:template&gt;</td></tr></tbody></table></div></div><p>

The first layer of tags is just a way to name a block of HTML. The container file could then reference them as <tt>{html}</tt> and <tt>{leftcolumn}</tt>.</p><p>Or another approach could be:
</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="c">// index.tpl</span></td></tr><tr><td class="number">2</td><td><span class="k3">&lt;</span>mef:template container<span class="k3">=</span><span class="s">"three-columns"</span> sidebar<span class="k3">=</span><span class="s">"Depot,Resources"</span><span class="k3">&gt;</span></td></tr><tr><td class="number">3</td><td>  <span class="c">// blah</span></td></tr><tr><td class="number">4</td><td><span class="k3">&lt;</span><span class="k3">/</span>mef:template&gt;</td></tr><tr><td class="number">5</td><td>&#160;</td></tr><tr><td class="number">6</td><td><span class="c">// three-columns.tpl</span></td></tr><tr><td class="number">7</td><td><span class="k3">&lt;</span>html&gt;</td></tr><tr><td class="number">8</td><td>&#160;</td></tr><tr><td class="number">9</td><td><span class="k3">&lt;</span>body&gt;</td></tr><tr><td class="number">10</td><td>&#160;</td></tr><tr><td class="number">11</td><td><span class="k3">&lt;</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_134.html" target="_blank">div</a> id<span class="k3">=</span><span class="s">"left-column"</span><span class="k3">&gt;</span></td></tr><tr><td class="number">12</td><td>  <span class="k3">&lt;</span>acc:column resources<span class="k3">=</span><span class="s">"{sidebar}"</span> <span class="k3">/</span><span class="k3">&gt;</span>  <span class="c">// a custom tag written in PHP</span></td></tr><tr><td class="number">13</td><td><span class="k3">&lt;</span><span class="k3">/</span>div&gt;</td></tr><tr><td class="number">14</td><td>&#160;</td></tr><tr><td class="number">15</td><td><span class="k3">&lt;</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_134.html" target="_blank">div</a> id<span class="k3">=</span><span class="s">"main"</span><span class="k3">&gt;</span></td></tr><tr><td class="number">16</td><td>  <span class="k2">{</span>html<span class="k2">}</span></td></tr><tr><td class="number">17</td><td><span class="k3">&lt;</span><span class="k3">/</span>div&gt;</td></tr><tr><td class="number">18</td><td>&#160;</td></tr><tr><td class="number">19</td><td><span class="k3">&lt;</span><span class="k3">/</span>body&gt;</td></tr><tr><td class="number">20</td><td>&#160;</td></tr><tr><td class="number">21</td><td><span class="k3">&lt;</span><span class="k3">/</span>html&gt;</td></tr></tbody></table></div></div><p>

There&#39;s plenty of ways to do it. Obviously you want to keep the template files as close to pure HTML as possible. Sometimes this means creating custom tags that generate HTML that&#39;s otherwise hard to represent.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Mon, 25 Feb 2008 09:25:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>OK I got something figured out. Just need to put that down into code now. I have a question though, everything beyond the base directory of the domain is the Query string?</p><p>And I still don&#39;t get this line:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">class</span> News_Module extends Module implements IRequestHandler
</pre></div></div><p>

I mean, I thought I got it but I don&#39;t. I tried to code something similar and now I know my ignorance is bigger then I thought. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Tue, 26 Feb 2008 18:35:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>An interface is an empty class:
</p><div class="source-code snippet"><div class="inner"><pre>interface Foo
<span class="k2">{</span>
  <span class="k1">public</span> function bar<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>

<span class="k1">class</span> Bar implements Foo
<span class="k2">{</span>
<span class="k2">}</span>
<span class="c">// error - it has no function called bar</span>
</pre></div></div><p>
In a language like PHP, it&#39;s more of just a formality. It&#39;s just a way to make sure a class implements a set of functions.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Tue, 26 Feb 2008 21:10:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>OK I just got some of the basics working, pretty nifty I must say. So, do you actually have two separate methods in a module - that handle get and post requests? For example:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">public</span> function handle_get_request<span class="k2">(</span>httpreq $request<span class="k2">)</span><span class="k2">;</span>
<span class="k1">public</span> function handle_post_request<span class="k2">(</span>httpreq $request<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Although I do not see the benefit in this as you can just as easily handle everything as GET and then check for $_POST vars in the get handler. Maybe I can make some sort of automatic form handler for these things.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Thu, 28 Feb 2008 05:14:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I handle them separately just because there&#39;s an ideological difference: GET should be used when requesting a read-only page, and POST should be used when pushing data to a read/write page.</p><p>But technically there&#39;s little difference between them, and they could easily be handled together.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Thu, 28 Feb 2008 05:19:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t like the idea of splitting GET and POST. It would seem like the biggest advantage of this method comes from being able to GET a form and then POST to the same URL, and by splitting it, you make the code more modular and readable. But I&#39;ve found that much of the code is shared between the two requests (typically, the code for a POST request is just a preamble to the code for the GET request), and so you harm your readability by splitting it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Thu, 28 Feb 2008 05:26:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, but I handle it much differently within my CMS. I don&#39;t care what URL you submit the POST data to. It&#39;s all encapsulated within a POST wrapper request. So my POST request handler looks more like:
</p><div class="source-code snippet"><div class="inner"><pre>function handlePost<span class="k2">(</span>$post<span class="k2">)</span>
<span class="k2">{</span>
  <span class="k1">if</span> <span class="k2">(</span>$post-&gt;namespace <span class="k3">!</span><span class="k3">=</span> <span class="s">'News'</span><span class="k2">)</span> <span class="k1">return</span> <span class="k1">false</span><span class="k2">;</span>

  <span class="k1">switch</span> <span class="k2">(</span>$post-&gt;action<span class="k2">)</span>
  <span class="k2">{</span>
    <span class="k1">case</span> <span class="s">'delete'</span><span class="k2">:</span>
      <span class="c">// check permissions</span>
      <span class="c">// validate fields</span>
      <span class="c">// perform operation</span>
      <span class="c">// redirect</span>
    <span class="k1">break</span><span class="k2">;</span>
  <span class="k2">}</span>
<span class="k2">}</span>
</pre></div></div><p>
This is because I don&#39;t want the CMS to define the URLs for all the applications it hosts. In short, you make a request with the namespace/action (e.g., News.Delete) along with a redirect URL on success (if wanted).</p><p>If you don&#39;t redirect and there is no error, then the &quot;GET&quot; request handler would kick in.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Thu, 28 Feb 2008 05:36:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>OK, I got it working with a prefixed set of Modules. Now, does PHP have any INI handling functions? Yeah, I know I can write my own and quite easily. But, just to avoid the hassle... Is there?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Fri, 29 Feb 2008 01:08:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><a href="http://us.php.net/parse_ini_file">http://us.php.net/parse_ini_file</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Fri, 29 Feb 2008 01:22:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Great, got everything working. Except one little thing. For example, www.mysite.com/ should display the news. So, it works if the url is www.mysite.com/news/ or something but how do I do it if no params are defined? </p><p>EDIT:</p><p>Another thing, lets say you have a Statistics module. Now, this has to be called in every page. But if News is first and the param is <i>news</i> then News module will return true and loading of modules stops there. Confusion! <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Fri, 29 Feb 2008 02:01:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Great, got everything working. Except one little thing. For example, www.mysite.com/ should display the news. So, it works if the url is www.mysite.com/news/ or something but how do I do it if no params are defined?
</p></div></div><p>
I don&#39;t understand your problem. There&#39;s nothing stopping any module from handling any request.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Another thing, lets say you have a Statistics module. Now, this has to be called in every page. But if News is first and the param is <i>news</i> then News module will return true and loading of modules stops there. Confusion!
</p></div></div><p>
A module could do something transparent within the handleRequest (e.g., log to a database), but still return FALSE as to say that it didn&#39;t handle the request. Just make sure the Statistics module is loaded first. I treat the INI file as first come, first serve. That&#39;s been good enough for me.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Fri, 29 Feb 2008 02:14:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I don&#39;t understand your problem. There&#39;s nothing stopping any module from handling any request.
</p></div></div><p>

Well I have something like this:
</p><div class="source-code snippet"><div class="inner"><pre>$request <span class="k3">=</span> <span class="k1">new</span> HTTPRequest<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
$request-&gt;path <span class="k3">=</span> <span class="c">/* ... */</span><span class="k2">;</span>

$<span class="k1">return</span> <span class="k3">=</span> <span class="k1">false</span><span class="k2">;</span>
foreach<span class="k2">(</span>$modules as $<a href="http://www.allegro.cc/manual/key" target="_blank"><span class="a">key</span></a> <span class="k3">=</span><span class="k3">&gt;</span> $value<span class="k2">)</span>
<span class="k2">{</span>
    <span class="k1">if</span><span class="k2">(</span>$value <span class="k3">=</span><span class="k3">=</span> <span class="s">"active"</span><span class="k2">)</span>
    <span class="k2">{</span>
        $module <span class="k3">=</span> $system-&gt;load_module<span class="k2">(</span>$<a href="http://www.allegro.cc/manual/key" target="_blank"><span class="a">key</span></a><span class="k2">)</span><span class="k2">;</span>
        $<span class="k1">return</span> <span class="k3">=</span> $module-&gt;handle_http_request<span class="k2">(</span>$request<span class="k2">)</span><span class="k2">;</span>
        <span class="k1">if</span><span class="k2">(</span>$<span class="k1">return</span> <span class="k3">=</span><span class="k3">=</span><span class="k3">=</span> <span class="k1">true</span><span class="k2">)</span> <span class="k1">break</span><span class="k2">;</span>   <span class="c">/* This line is the culprit I guess */</span>
    <span class="k2">}</span>
<span class="k2">}</span>
</pre></div></div><p>

But you already answered that question:</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
A module could do something transparent within the handleRequest (e.g., log to a database), but still return FALSE as to say that it didn&#39;t handle the request. Just make sure the Statistics module is loaded first. I treat the INI file as first come, first serve. That&#39;s been good enough for me.
</p></div></div><p>

But that seems so, hackish, interfering with the natural flow of the PHP code is a dangerous business indeed. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /> </p><p>I could implement something like an always_load option or something similar, but your solution sounds so much simpler! <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Fri, 29 Feb 2008 02:19:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There are various ways to solve it. In this particular case, I actually just rolled logging into the main application class. I build my CMS (actually it&#39;s a framework with a CMS module) on the fly. So while it may be useful to loop through the modules twice, by first calling a pre-processing function, I&#39;ve just not had the need to yet.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Fri, 29 Feb 2008 02:53:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That preprocessor function idea is great! There could be a handle_preprocessing() function! No double looping! <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /> This is just great! </p><p>Well, this is basically everything I need for now. Just one tiny question. Its about style, its not particularly relevant, but I would like to know anyway.</p><p>What is better, that every class is extended from System and that System has all the functions that the module could use:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">class</span> Foo <span class="c">// Is it possible to extend from 2 different classes?</span>
<span class="k2">{</span>
    <span class="k1">public</span> function Bar<span class="k2">(</span><span class="k2">)</span>
    <span class="k2">{</span>
        <span class="c">// If that is not possible, this could be a solution:</span>
        global $<a href="http://www.delorie.com/djgpp/doc/libc/libc_802.html" target="_blank">system</a><span class="k2">;</span>

        $result <span class="k3">=</span> $system-&gt;db-&gt;query<span class="k2">(</span><span class="s">"SELECT something FROM everything"</span><span class="k2">)</span><span class="k2">;</span>
        <span class="c">/* ... Moar code ... */</span>
    <span class="k2">}</span>
<span class="k2">}</span>
</pre></div></div><p>

This seems like its quaint. But yeah, I am infected from the &quot;perfect design&quot; virus. If its not perfect, its not good! Damn, I need to get over this! <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Fri, 29 Feb 2008 03:46:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You can only extend one class. </p><p>I do this:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">class</span> Module_Foo extends Module
<span class="k2">{</span>
  <span class="k1">public</span> function bar<span class="k2">(</span><span class="k2">)</span>
  <span class="k2">{</span>
    $app <span class="k3">=</span> Application::getInstance<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>

    <span class="c">// in reality, I rarely make direct calls like this. </span>
    <span class="c">// usually an object (e.g., DBO_New) is used.</span>
    $st <span class="k3">=</span> $app-&gt;db-&gt;prepare<span class="k2">(</span><span class="s">'...'</span><span class="k2">)</span><span class="k2">;</span>
    $results <span class="k3">=</span> $st-&gt;getAll<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
  <span class="k2">}</span>
<span class="k2">}</span>
</pre></div></div><p>

I wanted to avoid using globals, although there&#39;s really nothing wrong with it considering PHP&#39;s syntax can otherwise get cumbersome (thanks to its retarded scope rules). Or you could create a <tt>$this-&gt;app</tt> variable in the Module constructor.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Fri, 29 Feb 2008 03:56:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sorry for being stupid, but how is DBO_New used?</p><p>I&#39;m suspecting:
</p><div class="source-code snippet"><div class="inner"><pre><span class="c">/* ... class ... */</span>
    $db <span class="k3">=</span> DBO_New<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="c">/* ... */</span>
</pre></div></div><p>
?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Fri, 29 Feb 2008 04:01:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It&#39;s supposed to be &quot;DBO_News.&quot; DBO stands for &quot;database object,&quot; but it&#39;s sort of a misnomer in that it doesn&#39;t necessarily have to be stored in the database. There&#39;s nothing exposed in the interface that requires it. </p><p>Basically a DBO is any conceptual object. It may or may not correspond one to one with a database table.</p><div class="source-code snippet"><div class="inner"><pre>$news <span class="k3">=</span> DBO_News::find<span class="k2">(</span>$foo<span class="k2">)</span><span class="k2">;</span> <span class="c">// the constructor is private</span>
<span class="k1">if</span> <span class="k2">(</span>$news<span class="k2">)</span>
<span class="k2">{</span>
  $news-&gt;title <span class="k3">=</span> <span class="s">"A new title"</span><span class="k2">;</span>
  <span class="c">// or $news['title'] = "A new title";</span>
  $news-&gt;update<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

It gives me runtime flexibility to only query the data I need. For instance:</p><div class="source-code snippet"><div class="inner"><pre>$recent_news <span class="k3">=</span> DBO_News::findRecent<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
foreach <span class="k2">(</span>$recent_news as $news<span class="k2">)</span>
<span class="k2">{</span>
  echo $news-&gt;reporter-&gt;name . <span class="s">"&lt;br /&gt;"</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

The &quot;reporter&quot; isn&#39;t actually loaded by the initial query. It&#39;s used on demand. </p><p>Yes, this generates more SQL than is needed, but I don&#39;t care. The reason is that I cache HTML and data objects in memory if needed for performance. </p><p>In the above example, the <tt>findRecent()</tt> will generate a query that returns an array of news items without any linked information. Then for every unique <tt>reporter_id</tt>, it will load on demand the data for that person. That reporter data is then stored in memory so that the next time the page loads, only one query is run (<tt>findRecent()</tt>).</p><p>This is accomplished by:
</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="k1">class</span> DBO_News extends DBO</td></tr><tr><td class="number">2</td><td><span class="k2">{</span></td></tr><tr><td class="number">3</td><td>  <span class="k1">public</span> function __get<span class="k2">(</span>$<a href="http://www.allegro.cc/manual/key" target="_blank"><span class="a">key</span></a><span class="k2">)</span></td></tr><tr><td class="number">4</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">5</td><td>    <span class="k1">switch</span> <span class="k2">(</span>$<a href="http://www.allegro.cc/manual/key" target="_blank"><span class="a">key</span></a><span class="k2">)</span></td></tr><tr><td class="number">6</td><td>    <span class="k2">{</span></td></tr><tr><td class="number">7</td><td>      <span class="k1">case</span> <span class="s">'reporter'</span><span class="k2">:</span></td></tr><tr><td class="number">8</td><td>        <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span>$this-&gt;_reporter<span class="k2">)</span></td></tr><tr><td class="number">9</td><td>          $this-&gt;_reporter <span class="k3">=</span> DBO_User::find<span class="k2">(</span>$this-&gt;data<span class="k2">[</span><span class="s">'reporter_id'</span><span class="k2">]</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">10</td><td>&#160;</td></tr><tr><td class="number">11</td><td>        <span class="k1">return</span> $this-&gt;_reporter<span class="k2">;</span></td></tr><tr><td class="number">12</td><td>      <span class="k1">break</span><span class="k2">;</span></td></tr><tr><td class="number">13</td><td> </td></tr><tr><td class="number">14</td><td>      default: <span class="k1">return</span> parent::__get<span class="k2">(</span>$<a href="http://www.allegro.cc/manual/key" target="_blank"><span class="a">key</span></a><span class="k2">)</span><span class="k2">;</span>     </td></tr><tr><td class="number">15</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">16</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">17</td><td><span class="k2">}</span></td></tr></tbody></table></div></div><p>

The generic <tt>find()</tt> automatically will pull from memory if it can, thus eliminating simple one-off queries. </p><p>Again, this may seem like overkill if you know exactly how you will be using your data. But I chose this design with my templates in mind. I don&#39;t know when they will want to use extended information, nor do I want to force the template designers to use some SQL like syntax to inform PHP what to grab.</p><p>In this template, no extended data is used or queried:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k3">&lt;</span>ul&gt;
  <span class="k3">&lt;</span>li mef:loop<span class="k3">=</span><span class="s">"n; news"</span><span class="k3">&gt;</span>
    <span class="k2">{</span>n.title<span class="k2">}</span>
  <span class="k3">&lt;</span><span class="k3">/</span>li&gt;
<span class="k3">&lt;</span><span class="k3">/</span>ul&gt;
</pre></div></div><p>

But it&#39;s possible it might look like:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k3">&lt;</span>ul&gt;
  <span class="k3">&lt;</span>li mef:loop<span class="k3">=</span><span class="s">"n; news"</span><span class="k3">&gt;</span>
    <span class="k2">{</span>n.title<span class="k2">}</span>, reported by <span class="k2">{</span>n.reporter.name<span class="k2">}</span>
  <span class="k3">&lt;</span><span class="k3">/</span>li&gt;
<span class="k3">&lt;</span><span class="k3">/</span>ul&gt;
</pre></div></div><p>

Or even...
</p><div class="source-code snippet"><div class="inner"><pre><span class="k3">&lt;</span>ul&gt;
  <span class="k3">&lt;</span>li mef:loop<span class="k3">=</span><span class="s">"n; news"</span><span class="k3">&gt;</span>
    <span class="k2">{</span>n.title<span class="k2">}</span>, reported by <span class="k2">{</span>n.reporter.name<span class="k2">}</span> who has a game called <span class="k2">{</span>n.reporter.projects<span class="k2">[</span><span class="n">0</span><span class="k2">]</span>.title<span class="k2">}</span>
  <span class="k3">&lt;</span><span class="k3">/</span>li&gt;
<span class="k3">&lt;</span><span class="k3">/</span>ul&gt;
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Fri, 29 Feb 2008 04:18:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>OK, but does the Module implement DBO News or is it a system object? I am thinking of letting each module have its own folder and then can have all classes it wants in there. That way the module-ness is not lost.</p><p>Oh, by the way, is it even useful to have these:
</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// include.php</span>
<span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>defined<span class="k2">(</span><span class="s">"IN_SITE"</span><span class="k2">)</span><span class="k2">)</span> die<span class="k2">;</span>

<span class="c">// index.php</span>
define<span class="k2">(</span><span class="s">"IN_SITE"</span>, <span class="k1">true</span><span class="k2">)</span><span class="k2">;</span>
include <span class="s">"include.php"</span><span class="k2">;</span>
</pre></div></div><p>

I&#39;m getting bad headaches because of these plus __autoload! :S
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Sat, 01 Mar 2008 17:31:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The DBO objects live outside of the modules. They can be used with or without the rest of the framework. Module_News &quot;knows&quot; that DBO_News exists, but the reverse isn&#39;t true. The other modules probably never need to use DBO_News, but they could if need be. </p><p>I don&#39;t know what you mean by your include question. (I don&#39;t even use includes.)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Sat, 01 Mar 2008 22:38:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Its used so someone doesn&#39;t access your classes by doing:</p><pre>
<a href="http://www.mysite.com/include/myclass.class.php">http://www.mysite.com/include/myclass.class.php</a>
</pre><p>

And the defines are there to kill the script if its accessed directly. But I know what your gonna say, you have all the include files out of the web directory! <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Sat, 01 Mar 2008 23:54:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Oh, by the way, is it even useful to have these:
</p></div></div><p>No. Your include file doesn&#39;t execute any code, it just defines functions and classes. If a user accessed it, it would be a blank page.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Sat, 01 Mar 2008 23:57:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
And the defines are there to kill the script if its accessed directly. But I know what your gonna say, you have all the include files out of the web directory! <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div></div><p>
Yes, I do.
</p><pre>
class/                      All of my classes, including modules, DBOs, etc
template/                   System-wide (default / generic) templates 
site/dispatcher.php         The driver for everything
site/domain.com/template    Website templates
site/domain.com/web         Static Web Files (this is the doc root)
</pre><p>
That&#39;s a subset of the directories I use. Each website has a mod_rewrite that directs everything to /.dispatcher.php which is just an Alias to the global dispatcher.php file.</p><p>Anything in the &quot;web&quot; directory can be accessed directly by the web browser, but in general it&#39;s just static images and downloads. Occasionally I may slip a PHP file in there, but only has a hack because I&#39;m not interested (at the time) in creating a proper module for the functionality.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Sun, 02 Mar 2008 00:09:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m interested in how thats actually setup, do you place it all in /var/www and have just one virtual host setup in apache? or?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 02 Mar 2008 17:16:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It&#39;s in /var/www/cms (I have other regular sites in /var/www/domain.com) with each cms-driven domain having its own vhost pointing to /var/www/cms/site/domain.com/web.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Sun, 02 Mar 2008 21:04:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ah, I figured as much, and the &quot;links&quot; are actual symlinks to the main controller?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 02 Mar 2008 22:00:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Each sites&#39; vhost has an Alias from /.dispatcher.php (which doesn&#39;t exist) to /var/www/cms/site/dispatcher.php. That&#39;s the only kind of link between the two. That main dispatcher handles everything via the classes that sit in the cms/class directory.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Sun, 02 Mar 2008 22:17:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Haha I&#39;m so lucky this thread isn&#39;t dead yet! <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /> Time is of essence. </p><p>So, I still don&#39;t get it. What if there is no parameter in Request-&gt;path? What does a  module show then? Index.tpl? This is now bugging me for some time and I just can&#39;t seem to get it yet... My brain is hardwired with page-based thinking! <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Fri, 07 Mar 2008 05:46:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Use whatever method that makes you happy inside. For me a path like <tt>/foo/bar/blah?z=y</tt> would look like (in JSON):
</p><pre>
{
  path: [&#39;foo&#39;, &#39;bar&#39;, &#39;blah&#39;],
  params: {z: &#39;y&#39;}
}
</pre><p>
A path like <tt>/</tt> just becomes:
</p><pre>
{
  path: []
  params: {}
}
</pre><p>

I don&#39;t treat it as a special case. If nothing implements the empty request, then a 404 would be triggered just as if someone went to &#39;/asdfsadfasdfasdf&#39;.</p><p>So you could create a <tt>Module_EmptyRequest</tt> if you wanted. It could just load index.tpl.</p><p>I always load <tt>Module_AutoTemplate</tt> as the last, catch-all module. It just looks for any matching template. So /foo/bar would match in order: /foo/bar/index.tpl, /foo/bar.tpl, /foo/index.tpl, /foo.tpl, /index.tpl.</p><p>The null case just naturally searches for /index.tpl.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Fri, 07 Mar 2008 05:57:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Matthew: what is your opinion on the CakePHP-style request handling like <a href="http://www.allegro.cc/forums/thread/595252/730584#target">at the bottom of this post</a>?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Fri, 07 Mar 2008 07:20:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Are you referring to requiring that function names match the URL? I don&#39;t like it. But there&#39;s nothing preventing taking my generic request handler function and farming out requests to individual methods.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Fri, 07 Mar 2008 07:31:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Still not sure what to do... I could let the News module handle the empty request and just display the page as the index. I could implement an Empty request module and when an empty request happens I fetch the news and everything thats needed on the front page and display it. </p><p>Anyway, while this thread is still open, could anyone help me with a regex? I need a regex for something like this:</p><div class="source-code snippet"><div class="inner"><pre><span class="k3">&lt;</span>lang string<span class="k3">=</span><span class="s">"SOMETHING"</span> args<span class="k3">=</span><span class="k2">(</span>$foo, $bar<span class="k2">)</span><span class="k3">/</span><span class="k3">&gt;</span>
</pre></div></div><p>

This would be translated into:</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.delorie.com/djgpp/doc/libc/libc_737.html" target="_blank">sprintf</a><span class="k2">(</span>$language<span class="k2">[</span>SOMETHING<span class="k2">]</span>, $foo, $bar<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

I&#39;m currently trying with a regex but it wont work no matter what I do. My regex skills are broken.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Sun, 09 Mar 2008 00:27:43 +0000</pubDate>
	</item>
</rss>
