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

<channel>
	<title>CodeBlog.ch</title>
	<atom:link href="http://www.codeblog.ch/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codeblog.ch</link>
	<description>Coding and more - Concrete5, Flex, JavaScript</description>
	<lastBuildDate>Fri, 18 Jun 2010 08:05:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Concrete5 &#8211; Using TinyMCE Templates</title>
		<link>http://www.codeblog.ch/2010/06/concrete5-using-tinymce-templates/</link>
		<comments>http://www.codeblog.ch/2010/06/concrete5-using-tinymce-templates/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 08:05:06 +0000</pubDate>
		<dc:creator>Remo Laubacher</dc:creator>
				<category><![CDATA[Concrete5]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.codeblog.ch/?p=449</guid>
		<description><![CDATA[The Concrete5 content block uses TinyMCE as its WYSIWYG editor. Thanks to this decision, we are able to use several plugins most Concrete5 users haven&#8217;t thought about.
One feature I really like is the &#8220;template&#8221; plugin which allows you to create html snippets which you can insert into the content block. In this tutorial I&#8217;m going [...]]]></description>
			<content:encoded><![CDATA[<p>The Concrete5 content block uses TinyMCE as its WYSIWYG editor. Thanks to this decision, we are able to use several plugins most Concrete5 users haven&#8217;t thought about.</p>
<p>One feature I really like is the &#8220;template&#8221; plugin which allows you to create html snippets which you can insert into the content block. In this tutorial I&#8217;m going to show you, how you can create a simple 2 and 3 column table template.</p>
<h2>TinyMCE Configuration</h2>
<p>You&#8217;ll find almost anything you have to know on this page: <a href="http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/template">http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/template</a>. But luckily for you, I&#8217;m going to make this even easier for you.</p>
<p>First, you have to go to the Dashboard &#8211; Sitewide Settings. In the bottom right corner, you can activate a &#8220;Custom&#8221; configuration for the rich text editor. Once you&#8217;ve enabled it, it will show you some options. What do we need to activate the TinyMCE templates:</p>
<ul>
<li>We have to load the template plugin</li>
<li>There must be a button to display the template dialog</li>
<li>We have to create at least one template</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">theme <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;concrete&quot;</span><span style="color: #339933;">,</span> 
plugins<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;inlinepopups,spellchecker,safari,advlink,template&quot;</span><span style="color: #339933;">,</span>
editor_selector <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;ccm-advanced-editor&quot;</span><span style="color: #339933;">,</span>
spellchecker_languages <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;+English=en&quot;</span><span style="color: #339933;">,</span>	
theme_concrete_buttons1 <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;template,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,hr,|,styleselect,formatselect,fontsizeselect&quot;</span><span style="color: #339933;">,</span>
theme_concrete_buttons2 <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,forecolor&quot;</span><span style="color: #339933;">,</span>
theme_concrete_blockformats <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;p,address,pre,h1,h2,h3,div,blockquote,cite&quot;</span><span style="color: #339933;">,</span>
theme_concrete_toolbar_align <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;left&quot;</span><span style="color: #339933;">,</span>
theme_concrete_fonts <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats&quot;</span><span style="color: #339933;">,</span>
theme_concrete_font_sizes <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;1,2,3,4,5,6,7&quot;</span><span style="color: #339933;">,</span>
theme_concrete_styles<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Note=ccm-note&quot;</span><span style="color: #339933;">,</span>
spellchecker_languages <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;+English=en&quot;</span><span style="color: #339933;">,</span>
template_templates <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
	<span style="color: #009900;">&#123;</span>
		title <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;2 Columns&quot;</span><span style="color: #339933;">,</span>
		src <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;themes/yourTheme/templates/2_columns.html&quot;</span><span style="color: #339933;">,</span>
		description <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Adds a 2 columns table&quot;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	<span style="color: #009900;">&#123;</span>
		title <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;3 Columns&quot;</span><span style="color: #339933;">,</span>
		src <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;themes/yourTheme/templates/3_columns.html&quot;</span><span style="color: #339933;">,</span>
		description <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Adds a 3 columns table&quot;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#93;</span></pre></div></div>

<p>There&#8217;s one thing you probably have to change. In the two templates I&#8217;ve added, there&#8217;s a hardcoded path which won&#8217;t work on your site. Make sure it points to an existing directory. The content of the html file is rather simple. I modified the example for TinyMCE to make it look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xhtml" style="font-family:monospace;">&lt;!-- This will not be inserted --&gt;
&lt;div class=&quot;mceTmpl&quot;&gt;
&lt;table width=&quot;98%&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;
&lt;tr&gt;
&lt;th scope=&quot;col&quot;&gt;HEADER 1&lt;/th&gt;
&lt;th scope=&quot;col&quot;&gt;HEADER 2&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sample Data&lt;/td&gt;
&lt;td&gt;Sample Data&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;</pre></div></div>

<h2>How you can insert an HTML snippet</h2>
<p>You&#8217;re already done, but where can you find the snippets? We you add a new content block, you&#8217;ll see a new button:<br />
<img src="http://www.codeblog.ch/wp-content/uploads/2010/06/template-button-492x400.png" alt="" title="template-button" width="492" height="400" class="alignnone size-medium wp-image-451" /></p>
<p>When you click on this button, you&#8217;ll see a dialog where you can select the template:</p>
<p><img src="http://www.codeblog.ch/wp-content/uploads/2010/06/templates-471x400.png" alt="" title="templates" width="471" height="400" class="alignnone size-medium wp-image-452" /></p>
<p>Unfortunately, the insert button is a bit hidden, you have to scroll down to insert the template. You can insert as many snippets into one content block as you want:</p>
<p><img src="http://www.codeblog.ch/wp-content/uploads/2010/06/content-block-489x400.png" alt="" title="content-block" width="489" height="400" class="alignnone size-medium wp-image-453" /></p>
<p>I hope you like it and thanks for completely reading this tutorial! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeblog.ch/2010/06/concrete5-using-tinymce-templates/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Linux Shell in a Browser</title>
		<link>http://www.codeblog.ch/2010/02/linux-shell-in-a-browser/</link>
		<comments>http://www.codeblog.ch/2010/02/linux-shell-in-a-browser/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 12:37:43 +0000</pubDate>
		<dc:creator>Remo Laubacher</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.codeblog.ch/?p=440</guid>
		<description><![CDATA[If you&#8217;re a *unix admin you probably like SSH a lot. Even if you have to work on a Windows computer you can simply download a small tool like Putty and you&#8217;re ready to work on your server. However, there are situations where not even Putty works &#8211; if you&#8217;re behind a firewall that filters [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re a *unix admin you probably like SSH a lot. Even if you have to work on a Windows computer you can simply download a small tool like <a href="http://putty.very.rulez.org/download.html">Putty</a> and you&#8217;re ready to work on your server. However, there are situations where not even Putty works &#8211; if you&#8217;re behind a firewall that filters the outgoing traffic as well. It usually makes sense to block outgoing SSH traffic in a big company because you could easily create an encrypted tunnel to move secret data to any server you want.</p>
<p>But there&#8217;s another way to access your server using SSH like tools without having to worry about encrypted tunnels or any other threats SSH could cause. It&#8217;s called <a href="http://code.google.com/p/shellinabox/">shellinabox</a> and can be found on Google Code.</p>
<p>If you&#8217;re working with debian like I do, you can even download a prebuilt deb file.<br />
<code lang="bash">wget http://shellinabox.googlecode.com/files/shellinabox_2.10-1_i386.deb<br />
dpkg -i shellinabox_2.10-1_i386.deb</code></p>
<p>The installer creates an init script located in /etc/init.d/shellinabox. As soon as it has been started you can access your shell using any webbrowser using an address like this: https://localhost:4200. But the port 4200 is usually not accessible if you&#8217;re working behind a firewall that blocks SSH traffic. Let&#8217;s use apache to redirect traffic from HTTPS to 4200. We have to enable mod_proxy if it&#8217;s not already active:</p>
<p><code lang="bash">/etc/apache2/mods-enabled<br />
ln -s ../mods-available/proxy.conf<br />
ln -s ../mods-available/proxy.load<br />
ln -s ../mods-available/proxy_http.load</code></p>
<p>Edit the site file where you want to add your shell, I used /etc/apache2/sites-available/default-ssl and added these lines:<br />
<code lang="bash">&lt;Location /shell&gt;<br />
ProxyPass	http://localhost:4200/<br />
Order 	allow,deny<br />
Allow	from all<br />
&lt;/Location&gt;</code></p>
<p>Shellinabox uses https by default as well and is accessible by any ip address. We want to change that, let&#8217;s edit this file /etc/init.d/shellinabox and add SHELLINABOX_ARGS (the last line in the following box):<br />
<code># Set some default values<br />
SHELLINABOX_DATADIR="${SHELLINABOX_DATADIR:-/var/lib/shellinabox}"<br />
SHELLINABOX_PORT="${SHELLINABOX_PORT:-4200}"<br />
SHELLINABOX_USER="${SHELLINABOX_USER:-shellinabox}"<br />
SHELLINABOX_GROUP="${SHELLINABOX_GROUP:-shellinabox}"<br />
SHELLINABOX_ARGS="--localhost-only --disable-ssl"</code></p>
<p>If you now restart all the services &#8220;/etc/init.d/shellinabox restart&#8221; and /etc/init.d/apache2 restart&#8221;, you&#8217;re shell can be accessed by https://localhost/shell from anywhere you want!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeblog.ch/2010/02/linux-shell-in-a-browser/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Concrete5 &#8211; Custom 404 page</title>
		<link>http://www.codeblog.ch/2010/01/concrete5-custom-404-page/</link>
		<comments>http://www.codeblog.ch/2010/01/concrete5-custom-404-page/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 11:32:55 +0000</pubDate>
		<dc:creator>Remo Laubacher</dc:creator>
				<category><![CDATA[Concrete5]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.codeblog.ch/?p=425</guid>
		<description><![CDATA[It hopefullly doesn&#8217;t happen very often but sometimes a user might enter an address which doesn&#8217;t exist. In most situations a simple page is displayed, telling him that the page doesn&#8217;t exist. Having some more detailled information can be very helpful, especially when you just relaunched your website. Google &#038; Co need a while to [...]]]></description>
			<content:encoded><![CDATA[<p>It hopefullly doesn&#8217;t happen very often but sometimes a user might enter an address which doesn&#8217;t exist. In most situations a simple page is displayed, telling him that the page doesn&#8217;t exist. Having some more detailled information can be very helpful, especially when you just relaunched your website. Google &#038; Co need a while to reindex your page and users will probably see &#8220;page not found&#8221; more frequently than usually.</p>
<p>Concrete5 allows you to customize this page but it needs a few modifications. Some of them are probably a bit hard to find &#8211; which is why I wrote this tutorial. The standard Concrete5 &#8220;page not found&#8221; page looks like this:</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2010/01/pagenotfound.png"><img src="http://www.codeblog.ch/wp-content/uploads/2010/01/pagenotfound-300x194.png" alt="pagenotfound" title="pagenotfound" width="300" height="194" class="alignnone size-medium wp-image-426" /></a> </p>
<p><span id="more-425"></span></p>
<p>As you can see, the layout uses the default concrete5 dashboard theme. First, we&#8217;d like to use our own theme! Open &#8220;config/site_theme_paths.php&#8221;, there are already a few commented examples in the file:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>  
&nbsp;
<span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'C5_EXECUTE'</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span>_<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Access Denied.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$v</span> <span style="color: #339933;">=</span> View<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$v</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setThemeByPath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/page_not_found'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;yourtheme&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* 
	you can override system layouts here  - but we're not going to by default 
&nbsp;
	For example: if you would like to theme your login page with the Green Salad theme,
	you would uncomment the lines below and change the second argument of setThemeByPath 
	to be the handle of the the Green Salad theme &quot;greensalad&quot; 
&nbsp;
$v = View::getInstance();
&nbsp;
$v-&gt;setThemeByPath('/login', &quot;yourtheme&quot;);
 // $v-&gt;setThemeByPath('/403', &quot;yourtheme&quot;);
 // $v-&gt;setThemeByPath('/register', &quot;yourtheme&quot;);
 // $v-&gt;setThemeByPath('/dashboard', &quot;yourtheme&quot;);
&nbsp;
*/</span></pre></td></tr></table></div>

<p>In line 5 and 6 you can see the two lines I&#8217;ve added. Make sure that you replace &#8220;yourtheme&#8221; with the name of your theme &#8211; identical to the directory name of your theme in the folder &#8220;themes&#8221;.</p>
<p>Make sure your theme has a file called view.php. It might look similar to this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'C5_EXECUTE'</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span>_<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Access Denied.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">inc</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'elements/header.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
 	&lt;div id=&quot;content&quot;&gt;
	   &lt;div id=&quot;body&quot;&gt;
	   	&lt;!-- begin --&gt;
	   	<span style="color: #000000; font-weight: bold;">&lt;?php</span>
	   	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$innerContent</span><span style="color: #339933;">;</span>
	   	<span style="color: #000000; font-weight: bold;">?&gt;</span>
	   	&lt;!-- end --&gt;
	   &lt;/div&gt;
	&lt;/div&gt;	
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">inc</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'elements/footer.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>$innerContent is where all the information is saved. </p>
<p>Once you&#8217;ve saved site_theme_paths.php your error page uses your own theme. In my case like this:</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2010/01/pagenotfound-custom.png"><img src="http://www.codeblog.ch/wp-content/uploads/2010/01/pagenotfound-custom-300x205.png" alt="pagenotfound-custom" title="pagenotfound-custom" width="300" height="205" class="alignnone size-medium wp-image-429" /></a></p>
<h2>Sitemap</h2>
<p>It might make sense to display a sitemap when a users landed on the 404 page. This is also easy to do. Create a copy of /concrete/single_pages/page_not_found.php here /single_pages/page_not_found.php. This makes sure we don&#8217;t modify files within the Concrete5 core. Open the file and make it look like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'C5_EXECUTE'</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span>_<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Access Denied.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;h1 class=&quot;error&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Page Not Found'</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/h1&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No page could be found at this address.'</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;br/&gt;&lt;br/&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Area<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Main&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$a</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;br/&gt;&lt;br/&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$bt</span> <span style="color: #339933;">=</span> BlockType<span style="color: #339933;">::</span><span style="color: #004000;">getByHandle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'autonav'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$bt</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">controller</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">orderBy</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'display_asc'</span><span style="color: #339933;">;</span>                    
<span style="color: #000088;">$bt</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">controller</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">displayPages</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'top'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$bt</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">controller</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">displaySubPages</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'all'</span><span style="color: #339933;">;</span>     
<span style="color: #000088;">$bt</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">controller</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">displaySubPageLevels</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'all'</span><span style="color: #339933;">;</span>                    
<span style="color: #000088;">$bt</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">render</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'view'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>		
&nbsp;
&lt;br/&gt;&lt;br/&gt;
&nbsp;
&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> DIR_REL<span style="color: #000000; font-weight: bold;">?&gt;</span>/&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Back to Home'</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;.</pre></td></tr></table></div>

<p>Lines 13 to 20 uses the autonav block to display a sitemap. That&#8217;s it! In my case the &#8220;page not found&#8221; page looks like this:<br />
<a href="http://www.codeblog.ch/wp-content/uploads/2010/01/pagenotfound-sitemap.png"><img src="http://www.codeblog.ch/wp-content/uploads/2010/01/pagenotfound-sitemap-300x203.png" alt="pagenotfound-sitemap" title="pagenotfound-sitemap" width="300" height="203" class="alignnone size-medium wp-image-432" /></a></p>
<p>A bit useless in my case but probably more helpful if you have more pages than I do.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeblog.ch/2010/01/concrete5-custom-404-page/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Image Navigation Items</title>
		<link>http://www.codeblog.ch/2009/12/image-navigation-items/</link>
		<comments>http://www.codeblog.ch/2009/12/image-navigation-items/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 09:01:59 +0000</pubDate>
		<dc:creator>Remo Laubacher</dc:creator>
				<category><![CDATA[Concrete5]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Autonav]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://www.codeblog.ch/?p=405</guid>
		<description><![CDATA[It&#8217;s been a while since I&#8217;ve posted the last tutorial. Due to some unexpected events I finally found some time to write a new one.
The default autonav Block in Concrete5 allows you to add a navigation/menu to your site in almost no time. But as soon as you want to use images it get a [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I&#8217;ve posted the last tutorial. Due to some unexpected events I finally found some time to write a new one.</p>
<p>The default autonav Block in Concrete5 allows you to add a navigation/menu to your site in almost no time. But as soon as you want to use images it get a bit more difficult. In this tutorial I&#8217;m going to show you, how you can specify pictures for each page and pull them in an autonav template.</p>
<p><span id="more-405"></span></p>
<h2>Page attributes</h2>
<p>Concrete5 allows you do add different kinds of attributes to your page. You can use them to manage meta tags, tags, notes, thumbnails or images for your navigation. First we have to create two new page attributes where we can select the pictures. One which will be shown if the page is currently active and one for inactive pages.</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/12/1_page_attribute.png"><img src="http://www.codeblog.ch/wp-content/uploads/2009/12/1_page_attribute-300x174.png" alt="1_page_attribute" title="1_page_attribute" width="300" height="174" class="alignnone size-medium wp-image-406" /></a></p>
<p>All the important information has a red overlay:</p>
<ul>
<li>Attribute type must be Image/File</li>
<li>The Handle is used in the template, make sure you remember it</li>
<li>The Name is just a description to explain what the use of the attribute is</li>
</ul>
<h2>Assign images</h2>
<p>We have two new attributes where we can assign some images. The following screenshot explains this:</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/12/2_set_pictures.png"><img src="http://www.codeblog.ch/wp-content/uploads/2009/12/2_set_pictures-300x186.png" alt="2_set_pictures" title="2_set_pictures" width="300" height="186" class="alignnone size-medium wp-image-407" /></a></p>
<ul>
<li>In the sitemap, open &#8220;Properties&#8221; for the page where you would like to see an image in the navigation</li>
<li>Go to the last tab &#8220;Custom Fields&#8221; and add the two fields you just created</li>
<li>Select the image you want to see if the page is active and inactive</li>
</ul>
<p>Do this for all the pages where you&#8217;d like to have an image instead of a text link. You can always add and modify the images for the pages. Even your end-user can add new image menu item this way. One of many reasons why page attributes are so powerful!</p>
<h2>Custom Autonav Template</h2>
<p>If you haven&#8217;t worked with custom template you should probably read this tutorial first: <a href="http://www.codeblog.ch/2009/03/concrete5-templates/">http://www.codeblog.ch/2009/03/concrete5-templates/</a>.</p>
<p>To create a new custom template, simply copy /concrete/blocks/autonav/view.php to /blocks/autonav/templates/image_navigation.php. You probably have to create the folders autonav and templates first.</p>
<p>Around line 55 you should see this code (might be different, depending on your c5 version:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCollectionID</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$_c</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCollectionID</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
	<span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'
	&lt;li class=&quot;nav-selected nav-path-selected&quot;&gt;&lt;a class=&quot;nav-selected nav-path-selected&quot; href=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$pageLink</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$ni</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_c</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCollectionID</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$selectedPathCIDs</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
	<span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'
	&lt;li class=&quot;nav-path-selected&quot;&gt;&lt;a class=&quot;nav-path-selected&quot; href=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$pageLink</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$ni</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'
	&lt;li&gt;&lt;a href=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$pageLink</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$ni</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>With some HTML and PHP knowledge you probably have already found the place which outputs the link text. It&#8217;s of course &#8220;$ni->getName()&#8221;. This is the code which we have to modify to display images if they&#8217;ve been selected.</p>
<p>We replace $ni->getName() with variables which will hold the html code for the image or the link text:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$linkTextActive</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ni</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$linkTextInactive</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ni</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$picOn</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_c</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pic_on'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$picOff</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_c</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pic_off'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$picOn</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$linkTextActive</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;img src=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$picOn</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getURL</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; alt=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$linkTextActive</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;/&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$picOff</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$linkTextInactive</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;img src=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$picOff</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getURL</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; alt=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$linkTextInactive</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;/&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCollectionID</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$_c</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCollectionID</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
	<span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'
	&lt;li class=&quot;nav-selected nav-path-selected&quot;&gt;&lt;a class=&quot;nav-selected nav-path-selected&quot; href=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$pageLink</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$linkTextActive</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_c</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCollectionID</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$selectedPathCIDs</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
	<span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'
	&lt;li class=&quot;nav-path-selected&quot;&gt;&lt;a class=&quot;nav-path-selected&quot; href=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$pageLink</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$linkTextActive</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'
	&lt;li&gt;&lt;a href=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$pageLink</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$linkTextInactive</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<ul>
<li>Line 1,2: The new variables</li>
<li>Line 4,5: Get the attribute values &#8211; the image</li>
<li>Line 7-12: Checks if the attribute has a value and replaces the link text</li>
</ul>
<p>Now you can add an autonav block, set all the properties and after you&#8217;ve added the block, click on it again an hit &#8220;Set Custom Template&#8221;. If you create our custom template in the correct folder, you should now be able to select it.</p>
<p>If everything worked you should now have a top navigation like this:</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/12/example.png"><img src="http://www.codeblog.ch/wp-content/uploads/2009/12/example-300x165.png" alt="example" title="example" width="300" height="165" class="alignnone size-medium wp-image-417" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeblog.ch/2009/12/image-navigation-items/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Expand/Collapse Block</title>
		<link>http://www.codeblog.ch/2009/10/expandcollapse-block/</link>
		<comments>http://www.codeblog.ch/2009/10/expandcollapse-block/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 20:40:11 +0000</pubDate>
		<dc:creator>Remo Laubacher</dc:creator>
				<category><![CDATA[Concrete5]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[collapse]]></category>
		<category><![CDATA[expand]]></category>
		<category><![CDATA[free]]></category>

		<guid isPermaLink="false">http://www.codeblog.ch/?p=383</guid>
		<description><![CDATA[Due to limited time I wasn&#8217;t able to write new articles for codeblog. This time there&#8217;s not going to be much text, just a free block which you can use for your site.


Dialog
The following screenshot shows you the dialog you can use to enter the information related to the expand block. There&#8217;s a special feature [...]]]></description>
			<content:encoded><![CDATA[<p>Due to limited time I wasn&#8217;t able to write new articles for codeblog. This time there&#8217;s not going to be much text, just a free block which you can use for your site.</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/10/expand.png"><img src="http://www.codeblog.ch/wp-content/uploads/2009/10/expand-300x159.png" alt="expand" title="expand" width="300" height="159" class="alignnone size-medium wp-image-395" /></a></p>
<p><span id="more-383"></span></p>
<h2>Dialog</h2>
<p>The following screenshot shows you the dialog you can use to enter the information related to the expand block. There&#8217;s a special feature which I haven&#8217;t seen before &#8211; you can select the template while adding a new block. No need to open a second dialog!</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/10/dialog.png"><img src="http://www.codeblog.ch/wp-content/uploads/2009/10/dialog-300x274.png" alt="dialog" title="dialog" width="300" height="274" class="alignnone size-medium wp-image-384" /></a></p>
<h2>Updates / Contribution</h2>
<p>If you have some nice arrows/layouts. Please contact me! I&#8217;d be happy to add them to this block which we could later publish on the Concrete5 Marketplace once it contains a few nice layouts!</p>
<h2>Download / Installation</h2>
<p><a href='http://www.codeblog.ch/wp-content/uploads/2009/10/remo_expand2.zip'>Download block here</a>.</p>
<p>Extract the zip file into /blocks/ and make sure you keep the directory &#8220;remo_expand&#8221;. It&#8217;s not a package yet and therefore must be extracted to blocks and not packages!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeblog.ch/2009/10/expandcollapse-block/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Concrete5 &#8211; Formular Layout anpassen</title>
		<link>http://www.codeblog.ch/2009/07/concrete5-form-layout/</link>
		<comments>http://www.codeblog.ch/2009/07/concrete5-form-layout/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 11:12:51 +0000</pubDate>
		<dc:creator>Remo Laubacher</dc:creator>
				<category><![CDATA[Concrete5]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://www.codeblog.ch/?p=368</guid>
		<description><![CDATA[Concrete5 has a nice form block which allows you to create a contact form within a few seconds. You don&#8217;t even need to have any html or php skills to create a simple file upload form. Unfortunately this block isn&#8217;t very easy to style. It uses some html markup which makes it a bit tricky [...]]]></description>
			<content:encoded><![CDATA[<p>Concrete5 has a nice form block which allows you to create a contact form within a few seconds. You don&#8217;t even need to have any html or php skills to create a simple file upload form. Unfortunately this block isn&#8217;t very easy to style. It uses some html markup which makes it a bit tricky to use CSS. However, it doesn&#8217;t mean it&#8217;s impossible! I&#8217;m going to show you how you can easily create a styles form using Concrete5 Custom Templates to produce this:</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/07/pic2.png"><img src="http://www.codeblog.ch/wp-content/uploads/2009/07/pic2-300x257.png" alt="Styles Form" title="Styles Form" width="300" height="257" class="alignnone size-medium wp-image-370" /></a></p>
<p><span id="more-368"></span></p>
<h2>Custom Templates</h2>
<p>If you don&#8217;t know anything about &#8220;Custom Templates&#8221;, you should probably read this article first: <a href="http://www.codeblog.ch/2009/03/concrete5-templates/">http://www.codeblog.ch/2009/03/concrete5-templates/</a>. In short: Concrete5 allows you to style any block using templates in case you need to change the html output and not only the css rules.</p>
<h2>Core modification</h2>
<p>There&#8217;s one small thing I didn&#8217;t want to modify in the custom template since it shouldn&#8217;t be printed anyways. This might change in a future version, but because it doesn&#8217;t break anything I&#8217;m going to make the &#8220;not recommendable&#8221; core change in this case. Open the file &#8220;concrete/blocks/form/controller.php&#8221; and go to line 667 as shown on this screenshot:</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/07/pic1.png"><img src="http://www.codeblog.ch/wp-content/uploads/2009/07/pic1-300x46.png" alt="pic1" title="pic1" width="300" height="46" class="alignnone size-medium wp-image-369" /></a></p>
<p>Remove &#8217;style=&#8221;width:95%&#8221;&#8216; as it makes css styling a bit nasty. Please note that this step isn&#8217;t necessary, it&#8217;s just about the layout!</p>
<h2>The default layout</h2>
<p>If you create a new form, it usually looks like this:</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/07/pic3.png"><img src="http://www.codeblog.ch/wp-content/uploads/2009/07/pic3-300x167.png" alt="pic3" title="pic3" width="300" height="167" class="alignnone size-medium wp-image-371" /></a></p>
<p>It works but doesn&#8217;t look very nice.</p>
<h2>New form style</h2>
<p>In this tutorial I&#8217;m showing you how you can create a form in which the labels are in the textfields and not on top or left. This might especially be useful if you have a very small page and a huge form. It also looks nice. </p>
<p>This is how the result is going to look like:<br />
<a href="http://www.codeblog.ch/wp-content/uploads/2009/07/pic2.png"><img src="http://www.codeblog.ch/wp-content/uploads/2009/07/pic2-300x257.png" alt="Styles Form" title="Styles Form" width="300" height="257" class="alignnone size-medium wp-image-370" /></a></p>
<p>Let me start with the php template view.php:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>    
<span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'C5_EXECUTE'</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span>_<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Access Denied.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$survey</span><span style="color: #339933;">=</span><span style="color: #000088;">$controller</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$miniSurvey</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> MiniSurvey<span style="color: #009900;">&#40;</span><span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$miniSurvey</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">frontEndMode</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;div class=&quot;ccm-form&quot; id=&quot;ccm-form-id-<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$bID</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$invalidIP</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;div class=&quot;ccm-error&quot;&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$invalidIP</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;form enctype=&quot;multipart/form-data&quot; id=&quot;miniSurveyView<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$bID</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; class=&quot;miniSurveyView&quot; method=&quot;post&quot; action=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">action</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'submit_form'</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span>   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'surveySuccess'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'qsid'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$survey</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">questionSetId</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;div id=&quot;msg&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$survey</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">thankyouMsg</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>   <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$formResponse</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;div id=&quot;msg&quot;&gt;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$formResponse</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;?php</span>  
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$errors</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$errors</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$errors</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$error</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'
&lt;div class=&quot;error&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$error</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/div&gt;
'</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;input name=&quot;qsID&quot; type=&quot;hidden&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span>  <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$survey</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">questionSetId</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
	&lt;input name=&quot;pURI&quot; type=&quot;hidden&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span>  <span style="color: #000088;">$pURI</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span>   	
	<span style="color: #000088;">$questionsRS</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$miniSurvey</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadQuestions</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$survey</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">questionSetId</span><span style="color: #339933;">,</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$bID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$surveyBlockInfo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$miniSurvey</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMiniSurveyBlockInfoByQuestionId</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$survey</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">questionSetId</span><span style="color: #339933;">,</span><span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$bID</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$showEdit</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$hideQIDs</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$questionRow</span><span style="color: #339933;">=</span><span style="color: #000088;">$questionsRS</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchRow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>	
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$questionRow</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'qID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$hideQIDs</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$msqID</span><span style="color: #339933;">=</span><span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$questionRow</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'msqID'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$requiredClass</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$questionRow</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'required'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>?<span style="color: #0000ff;">' required '</span><span style="color: #339933;">:</span><span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$requiredSymbol</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$questionRow</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'required'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>?<span style="color: #0000ff;">' *'</span><span style="color: #339933;">:</span><span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'
&lt;div class=&quot;ccm-form-element'</span><span style="color: #339933;">.</span><span style="color: #000088;">$requiredClass</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Question'</span><span style="color: #339933;">.</span><span style="color: #000088;">$msqID</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$questionRow</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'question'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$requiredSymbol</span><span style="color: #339933;">;</span>				
&nbsp;
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$miniSurvey</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadInputType</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$questionRow</span><span style="color: #339933;">,</span>showEdit<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/div&gt;
&quot;</span><span style="color: #339933;">;</span>	
	<span style="color: #009900;">&#125;</span>	
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$surveyBlockInfo</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'displayCaptcha'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>		
		<span style="color: #000088;">$captcha</span> <span style="color: #339933;">=</span> Loader<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'validation/captcha'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>				
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;
&lt;div class=<span style="color: #000099; font-weight: bold;">\&quot;</span>ccm-form-captcha<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'
&lt;div class=&quot;required&quot;&gt;'</span><span style="color: #339933;">;</span>		
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;input type=&quot;text&quot; value=&quot;Sicherheitscode hier eingeben&quot; name=&quot;ccmCaptchaCode&quot; class=&quot;ccm-input-captcha&quot;/&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// Please note that we need to style our captcha, we therefore create it manually!</span>
		<span style="color: #666666; font-style: italic;">//$captcha-&gt;showInput();</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/div&gt;
&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;
&lt;div&gt;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$captcha</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/div&gt;
&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/div&gt;
&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'
&lt;div style=&quot;clear:both&quot;&gt;&lt;/div&gt;
'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;input class=&quot;formBlockSubmitButton button&quot; name=&quot;Submit&quot; type=&quot;submit&quot; value=&quot;senden&quot; /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">?&gt;</span> 
&lt;/form&gt;&lt;/div&gt;</pre></td></tr></table></div>

<p>I&#8217;m not explaing each line because I assume you understand PHP, otherwise this tutorial isn&#8217;t made for you &#8211; sorry!<br />
What I changed:</p>
<ul>
<li>Calling some methods found in the controller out of the view</li>
<li>Created a div layout instead of a table layout</li>
<li>Added some CSS classes to indicate required fields</li>
<li>Added a strange line which makes sure that the value attribute of the textfield contain the description</li>
</ul>
<p>Now, we&#8217;ve got a form where we don&#8217;t have any labels next to the input fields. But we need to get rid of these values at some point, otherwise the users are able to submit forms using the default values (labels). To achieve this, we&#8217;re going to use some JavaScript checks:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.miniSurveyView input[type=text], textarea'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span>onEnterField<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.miniSurveyView input[type=text], textarea'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span>onEnterField<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.miniSurveyView input[type=text], textarea'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">blur</span><span style="color: #009900;">&#40;</span>onLeaveField<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>These events get raised once a users clicks into a textfield within our form. There we check whether we have to replace the label or not using this code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> onEnterField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">origLabel</span> <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
      <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">origLabel</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
   <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">origLabel</span> <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">||</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">origLabel</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span>
      <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
&nbsp;
	$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">prev</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.formError&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> onLeaveField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>	
   <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">''</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">origLabel</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
      <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">origLabel</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>We also add some client side checks to make sure the users has entered all the required fields. This allows us to safe a request and a few milliseconds of waiting.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.miniSurveyView input[type=text], textarea'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span>onEnterField<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.miniSurveyView input[type=text], textarea'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span>onEnterField<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.miniSurveyView input[type=text], textarea'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">blur</span><span style="color: #009900;">&#40;</span>onLeaveField<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.miniSurveyView'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> formErrors <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
&nbsp;
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.formError'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[type=text], textarea'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'origLabel'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> undefined <span style="color: #339933;">||</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'origLabel'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;required&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				formErrors<span style="color: #339933;">++;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">before</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'
&lt;div class=&quot;formError&quot; id=&quot;formError'</span><span style="color: #339933;">+</span>formErrors<span style="color: #339933;">+</span><span style="color: #3366CC;">'&quot; style=&quot;height:18px;color:red;font-size:10px;display:none;&quot;&gt;Bitte Wert eingeben:&lt;/div&gt;
'</span><span style="color: #009900;">&#41;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#formError&quot;</span> <span style="color: #339933;">+</span> formErrors<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">200</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>					
				<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>formErrors <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">else</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We check for all fields and make sure the have a value in case they&#8217;re underneath a div with the class &#8220;required&#8221;. We simply display a div above the input fields in case there&#8217;s a value missing.</p>
<p>The template also contains some css rules which I&#8217;m not going to show in this article. They&#8217;re pretty straight forward, but you can also find them here:</p>
<p><a href='http://www.codeblog.ch/wp-content/uploads/2009/07/codeblog.zip'>Download Form Template</a></p>
<p>Extract the zip into &#8220;blocks/form/templates&#8221;. You might have to create the diretories form and templates first!<br />
Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeblog.ch/2009/07/concrete5-form-layout/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Smart text trimming with PHP</title>
		<link>http://www.codeblog.ch/2009/06/smart-text-trimming-with-php/</link>
		<comments>http://www.codeblog.ch/2009/06/smart-text-trimming-with-php/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 12:56:46 +0000</pubDate>
		<dc:creator>Remo Laubacher</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[trim]]></category>

		<guid isPermaLink="false">http://www.codeblog.ch/?p=353</guid>
		<description><![CDATA[Have you ever tried to create a short preview text using PHP? Did you just count the characters and ended up having texts with a completely different width like shown on this picture?

This tutorial describes a small method which calculates the real width of a string and lets you create better looking preview texts!

Measuring string [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever tried to create a short preview text using PHP? Did you just count the characters and ended up having texts with a completely different width like shown on this picture?</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/06/text-trimming.png"><img src="http://www.codeblog.ch/wp-content/uploads/2009/06/text-trimming-300x255.png" alt="text-trimming" title="text-trimming" width="300" height="255" class="alignnone size-medium wp-image-354" /></a></p>
<p>This tutorial describes a small method which calculates the real width of a string and lets you create better looking preview texts!</p>
<p><span id="more-353"></span></p>
<h2>Measuring string width</h2>
<p>PHP offers several methods to measure a string width. You can use the built in method <a target="_blank" href="http://ch2.php.net/manual/en/function.imagefontwidth.php">ImageFontWidth</a> to measure the width of a string using the built in PHP fonts. This is quite easy and works well if you want to create a captcha or something similar, using the PHP fonts.</p>
<p>But there&#8217;s another method which you can easily use to get the complete bounding box of a true type font string. It&#8217;s called <a href="http://ch2.php.net/manual/en/function.imagettfbbox.php">imagettfbbox</a>. The return value is an array which contains several values needed for a bounding box.</h2>
<p>The trimming method</h2>
<p>As you&#8217;ve probably seen on the picure at the beginning of the article, I needed a method that cuts off a string after a certain width and adds a string to indicate that the text isn&#8217;t completely shown. Here&#8217;s some code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> trim_by_width<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span><span style="color: #000088;">$width</span><span style="color: #339933;">,</span><span style="color: #000088;">$font_file</span><span style="color: #339933;">,</span><span style="color: #000088;">$font_size</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span><span style="color: #000088;">$append_string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'...'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$append_string_box</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagettfbbox</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$font_size</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$font_file</span><span style="color: #339933;">,</span><span style="color: #000088;">$append_string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$append_string_width</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$append_string_box</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$str_len</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&lt;=</span><span style="color: #000088;">$str_len</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$trimmed_text</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$bounding_box</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagettfbbox</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$font_size</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$font_file</span><span style="color: #339933;">,</span><span style="color: #000088;">$trimmed_text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$trimmed_text_width</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$bounding_box</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$trimmed_text_width</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$append_string_width</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$width</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$str_to_return</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trimmed_text</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trimmed_text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$trimmed_text_width</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$str_len</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$str_to_return</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$append_string</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$str_to_return</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$text</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$trimmed_text</span> <span style="color: #339933;">=</span> trim_by_width<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$width</span><span style="color: #339933;">,</span> <span style="color: #000088;">$font_file</span><span style="color: #339933;">,</span> <span style="color: #000088;">$font_size</span><span style="color: #339933;">,</span> <span style="color: #000088;">$append_string</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'...'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>$text:<br />
<code>The first parameter is the string which you want to trim</code></p>
<p>$width:<br />
<code>This defines the maximum width of the text in pixels! Not in characters or anything else</code></p>
<p>$font_file:<br />
<code>Here you have to specify the location of your true type font file.</code></p>
<p>$font_size:<br />
<code>The font size you want to use. Please note that unit depends on the version of the GD library you're using. GD1 uses pixels, whereas GD2 uses points</code></p>
<p>$append_string:<br />
<code>An optional string to define the text appended at the end of a trimmed text. By default set to "..."</code></p>
<h2>An example</h2>
<p>You can call the method like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> trim_by_width<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'this is a long text'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">55</span><span style="color: #339933;">,</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/verdana.ttf'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>It assumes that the file verdana.ttf is in the same directory as the php script. It will cut the text &#8220;this is a long text&#8221; after 55 pixels.</p>
<p>That&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeblog.ch/2009/06/smart-text-trimming-with-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Concrete5 &#8211; more Speed with eAccelerator</title>
		<link>http://www.codeblog.ch/2009/06/concrete5-speed-eaccelerator/</link>
		<comments>http://www.codeblog.ch/2009/06/concrete5-speed-eaccelerator/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 10:38:30 +0000</pubDate>
		<dc:creator>Remo Laubacher</dc:creator>
				<category><![CDATA[Concrete5]]></category>
		<category><![CDATA[eAccelerator]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.codeblog.ch/?p=342</guid>
		<description><![CDATA[UPDATE: The latest eAccelerator version doens&#8217;t contain the PHP API anymore. It therefore does no longer work with Concrete5! The upcoming version 5.4 is going to have support for APC and memcache. Sorry!
You want more speed with Concrete5? Make sure you&#8217;re using eAccelerator!
In this tutorial I&#8217;ll explain how to install eAccelerator on a Debian Linux [...]]]></description>
			<content:encoded><![CDATA[<p>UPDATE: The latest eAccelerator version doens&#8217;t contain the PHP API anymore. It therefore does no longer work with Concrete5! The upcoming version 5.4 is going to have support for APC and memcache. Sorry!</p>
<p>You want more speed with Concrete5? Make sure you&#8217;re using <a href="http://eaccelerator.net/" target="_blank">eAccelerator</a>!</p>
<p>In this tutorial I&#8217;ll explain how to install eAccelerator on a Debian Linux Server.</p>
<p><a href="http://eaccelerator.net"><img src="http://www.codeblog.ch/wp-content/uploads/2009/06/eaccelerator1.png" alt="eaccelerator1" title="eaccelerator1" width="247" height="33" class="alignnone size-full wp-image-344" /></a></p>
<p><span id="more-342"></span></p>
<h2>Already installed?</h2>
<p>Create a page called info.php somehwere in a directory you can access using http://&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
   <span style="color: #990000;">phpinfo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Try to find &#8220;eAccelerator&#8221;. If you can&#8217;t find it, it&#8217;s not installed, go ahead with the following instructions.</p>
<h2>Install eAccelerator</h2>
<p>Open a console/ssh connection to your server and enter these commands:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>bart.eaccelerator.net<span style="color: #000000; font-weight: bold;">/</span>source<span style="color: #000000; font-weight: bold;">/</span>0.9.5.3<span style="color: #000000; font-weight: bold;">/</span>eaccelerator-0.9.5.3.tar.bz2
<span style="color: #c20cb9; font-weight: bold;">tar</span> xvfj eaccelerator-0.9.5.3.tar.bz2
<span style="color: #7a0874; font-weight: bold;">cd</span> eaccelerator-0.9.5.3
phpize
.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--with-eaccelerator-shared-memory</span> <span style="color: #660033;">--with-php-config</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php-config <span style="color: #660033;">--with-eaccelerator-userid</span>=www-data <span style="color: #660033;">--with-eaccelerator-content-caching</span> 
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>You might want to check whether 0.9.5.3 is still the latest version. As of the 12th of June 2009 it is.</p>
<p>Make sure there are no error messages before you continue.</p>
<p>Create the directory where you want to save the eAccelerator cache files:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>cache<span style="color: #000000; font-weight: bold;">/</span>eaccelerator
<span style="color: #c20cb9; font-weight: bold;">chmod</span> 0777 <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>cache<span style="color: #000000; font-weight: bold;">/</span>eaccelerator</pre></div></div>

<p>Create the config file for eAccelerator. Use a vi or any other text editor to create the config file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php5<span style="color: #000000; font-weight: bold;">/</span>conf.d<span style="color: #000000; font-weight: bold;">/</span>eaccelerator.ini</pre></div></div>

<p>Enter this content:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000099;">extension</span> <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;eaccelerator.so&quot;</span>
eaccelerator.shm_size <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;16&quot;</span>
eaccelerator.cache_dir <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;/var/cache/eaccelerator&quot;</span>
eaccelerator.enable <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;1&quot;</span>
eaccelerator.optimizer <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;1&quot;</span>
eaccelerator.check_mtime <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;1&quot;</span>
eaccelerator.debug <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;0&quot;</span>
eaccelerator.filter <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;&quot;</span>
eaccelerator.shm_ttl <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;0&quot;</span>
eaccelerator.shm_max <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;0&quot;</span>
eaccelerator.shm_prune_period <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;0&quot;</span>
eaccelerator.shm_only <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;0&quot;</span>
eaccelerator.compress <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;1&quot;</span>
eaccelerator.compress_level <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;9&quot;</span></pre></div></div>

<p>You can restart apache using this command now:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</pre></div></div>

<p>Open the info.php again and check whether you can see eAccelerator. If everything looks fine, go to the directory of your Concrete5 and edit &#8220;config/site.php&#8221; &#8211; add this line:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'CACHE_LIBRARY'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'eaccelerator'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Open your Concrete5 and feel the difference!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeblog.ch/2009/06/concrete5-speed-eaccelerator/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Concrete5 &#8211; Staff listing with two Columns</title>
		<link>http://www.codeblog.ch/2009/06/concrete5-staff-table/</link>
		<comments>http://www.codeblog.ch/2009/06/concrete5-staff-table/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 10:53:30 +0000</pubDate>
		<dc:creator>Remo Laubacher</dc:creator>
				<category><![CDATA[Concrete5]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[columns]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[person]]></category>
		<category><![CDATA[staff]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://www.codeblog.ch/?p=334</guid>
		<description><![CDATA[Sometimes content should be presented in two columns. In this tutorial I&#8217;ll describe a possible solution that included a very simple block to display a staff/team member with a description on the right side of it. The result will look like this:


Table layouts
I&#8217;m not going into the details about tableless layouts, just a few basic [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes content should be presented in two columns. In this tutorial I&#8217;ll describe a possible solution that included a very simple block to display a staff/team member with a description on the right side of it. The result will look like this:</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/06/staff1.jpg"><img src="http://www.codeblog.ch/wp-content/uploads/2009/06/staff1-300x212.jpg" alt="staff1" title="staff1" width="300" height="212" class="alignnone size-medium wp-image-335" /></a></p>
<p><span id="more-334"></span></p>
<h2>Table layouts</h2>
<p>I&#8217;m not going into the details about tableless layouts, just a few basic things. The table tag shouldn&#8217;t be used for a layout, using div &#038; css is the way to go. With Concrete5 you could theoretically create two areas but you would then have the problem that the content in the left column doesn&#8217;t have to same margin to the top as the content in the right.</p>
<p>I&#8217;m therefore describing a block that creates a proper div output which you can style using common css rules.</p>
<h2>The staff block</h2>
<p>The block contains only two elements. A picture and a textfield to enter a little note/description about the person.</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/06/staff2.jpg"><img src="http://www.codeblog.ch/wp-content/uploads/2009/06/staff2-294x300.jpg" alt="staff2" title="staff2" width="294" height="300" class="alignnone size-medium wp-image-336" /></a></p>
<p>The html output will look like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;ccm-person&quot;&gt;
   &lt;div class=&quot;ccm-person-image&quot;&gt;&lt;img src=&quot;http://myserver/remo.jpg&quot; alt=&quot;&quot;&gt;&lt;/div&gt;
   &lt;div class=&quot;ccm-person-description&quot;&gt;Lorem ipsum dolor sit ame.&lt;/div&gt;
   &lt;div style=&quot;clear:both&quot;&gt;&lt;/div&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p>Please note that I&#8217;ve added div at the end that uses an inline-style to clear the output. You might want to use a class of your theme but since there&#8217;s no class name that&#8217;s available everything, I&#8217;ve decided to use an inline-style to explain the block!</p>
<p>Without any styling this will generate an output where the text is shown underneath the picture. But since we want to have a table-like layout, we add a few lines to our css file:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.ccm-person-image</span> <span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">80px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.ccm-person-description</span> <span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">385px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>This is usually specific to your layout, change it to suit your needs!</p>
<p><a href='http://www.codeblog.ch/wp-content/uploads/2009/06/person.zip'>Download block</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeblog.ch/2009/06/concrete5-staff-table/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Concrete5 &#8211; CSS features [typograhy.css, customize themes]</title>
		<link>http://www.codeblog.ch/2009/05/concrete5-css-features/</link>
		<comments>http://www.codeblog.ch/2009/05/concrete5-css-features/#comments</comments>
		<pubDate>Sun, 03 May 2009 11:45:00 +0000</pubDate>
		<dc:creator>Remo Laubacher</dc:creator>
				<category><![CDATA[Concrete5]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[tinymce]]></category>

		<guid isPermaLink="false">http://www.codeblog.ch/?p=314</guid>
		<description><![CDATA[If you ever built your own Concrete5 theme you might have wondered why there are usually two css files &#8211; main.css and typography.css. In this tutorial I&#8217;ll show you some possibilities of typography.css. You should have basic knowledge about building a theme for Concrete5. Read this tutorial in case you never built one before: http://www.codeblog.ch/2009/01/concrete5-theme-erstellen/


Prequisites
In [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever built your own Concrete5 theme you might have wondered why there are usually two css files &#8211; main.css and typography.css. In this tutorial I&#8217;ll show you some possibilities of typography.css. You should have basic knowledge about building a theme for Concrete5. Read this tutorial in case you never built one before: <a href="http://www.codeblog.ch/2009/01/concrete5-theme-erstellen/">http://www.codeblog.ch/2009/01/concrete5-theme-erstellen/</a></p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/05/typo1.png"><img src="http://www.codeblog.ch/wp-content/uploads/2009/05/typo1-292x300.png" alt="typo1" title="typo1" width="292" height="300" class="alignnone size-medium wp-image-315" /></a></p>
<p><span id="more-314"></span></p>
<h2>Prequisites</h2>
<p>In this tutorial I&#8217;m using a simple theme which you can find in the Concrete5 <a href="http://www.concrete5.org/marketplace/">Marketplace</a>, it&#8217;s called <a href="http://www.concrete5.org/marketplace/themes/dreamy">Dreamy</a> and has been created by <a href="http://www.kilohanadesign.com/">Scott</a>.</p>
<p>I removed a few things in the theme which I don&#8217;t need to make it a bit easier to understand, but that&#8217;s not necessary.</p>
<h2>The page design</h2>
<p>I created a simple text page using the modified theme which looks like this:</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/05/typo1.png"><img src="http://www.codeblog.ch/wp-content/uploads/2009/05/typo1-292x300.png" alt="typo1" title="typo1" width="292" height="300" class="alignnone size-medium wp-image-315" /></a></p>
<p>Please note that I&#8217;ve changed the colors of H1 and H2. When you now edit this page, the WYSIWYG editor <a href="http://tinymce.moxiecode.com/">TinyMCE</a> looks like this:</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/05/typo2.png"><img src="http://www.codeblog.ch/wp-content/uploads/2009/05/typo2-300x240.png" alt="typo2" title="typo2" width="300" height="240" class="alignnone size-medium wp-image-316" /></a></p>
<p>The headings H1 and H2 are black. Wouldn&#8217;t it be nice if the user could see the typography there too? This is what typography.css is good for. Let us add a few lines to typography.css:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">h1 <span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#54bed4</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
h2 <span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#adc42c</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>By default, the WYSIWYG editor looks for the file called typography.css and includes all the styles too. By doing this, it allows you to add styles which can be displayed during the editing of a text to give the user a first impression about the text layout.</p>
<p>If you edit a text after you&#8217;ve added the css rules, the editor will look like this:</p>
<p><a href="http://www.codeblog.ch/wp-content/uploads/2009/05/typo3.png"><img src="http://www.codeblog.ch/wp-content/uploads/2009/05/typo3-300x237.png" alt="typo3" title="typo3" width="300" height="237" class="alignnone size-medium wp-image-317" /></a></p>
<p>You might have to clear your cache if you can&#8217;t see the changes!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeblog.ch/2009/05/concrete5-css-features/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>
