<?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>Richard Knop&#039;s Zend Framework Blog &#187; Web design</title>
	<atom:link href="http://blog.richardknop.com/category/web-design/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.richardknop.com</link>
	<description>Zend Framework, PHP, MySQL, jQuery, JavaScript, AJAX, SEO, E-commerce and more</description>
	<lastBuildDate>Mon, 06 Sep 2010 15:49:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Zend Framework content negotiation plugin</title>
		<link>http://blog.richardknop.com/2010/07/zend-framework-content-negotiation-plugin/</link>
		<comments>http://blog.richardknop.com/2010/07/zend-framework-content-negotiation-plugin/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 17:33:41 +0000</pubDate>
		<dc:creator>Richard Knop</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web design]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Content negotiation]]></category>

		<guid isPermaLink="false">http://blog.richardknop.com/?p=601</guid>
		<description><![CDATA[Even though most designers write nice and valid XHTML it usually gets served to browser as text/html. In other words, what browser sees is a chaotic tag soup instead of XML (remember that while HTML was based on SGML, XHTML is based on XML or it is a reformulation of HTML in XML). The major [...]]]></description>
			<content:encoded><![CDATA[<p>Even though most designers write nice and valid XHTML it usually gets served to browser as text/html. In other words, what browser sees is a chaotic tag soup instead of XML (remember that while HTML was based on SGML, XHTML is based on XML or it is a reformulation of HTML in XML). The major reason why XHTML pages are getting served as text/html is infamous Internet Explorer which does not support serving XHTML the correct way (as XML). But why should your website suffer because of one browser? You can serve the tag soup to IE and serve XML to other browsers. This is called <strong>content negotiation</strong> and I&#8217;m going to show you a simple Zend Fraemwork controller plugin that will negotiate different content to different browsers:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">class</span> My_Controller_Plugin_NegotiateContent <span class="kw2">extends</span> Zend_Controller_Plugin_Abstract</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">public</span> <span class="kw2">function</span> preDispatch<span class="br0">&#40;</span>Zend_Controller_Request_Abstract <span class="re1">$request</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$viewRenderer</span> <span class="sy0">=</span> Zend_Controller_Action_HelperBroker<span class="sy0">::</span><span class="me2">getExistingHelper</span><span class="br0">&#40;</span><span class="st0">&#39;ViewRenderer&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$viewRenderer</span><span class="sy0">-&gt;</span><span class="me1">initView</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$view</span> <span class="sy0">=</span> <span class="re1">$viewRenderer</span><span class="sy0">-&gt;</span><span class="me1">view</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// content negotiation</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">header</span><span class="br0">&#40;</span><span class="st0">&#39;Vary: Accept&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw2">false</span> <span class="sy0">===</span> <span class="kw3">stristr</span><span class="br0">&#40;</span><span class="re1">$_SERVER</span><span class="br0">&#91;</span><span class="st0">&#39;HTTP_ACCEPT&#39;</span><span class="br0">&#93;</span><span class="sy0">,</span> <span class="st0">&#39;application/xhtml+xml&#39;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">header</span><span class="br0">&#40;</span><span class="st0">&#39;Content-Type: text/html; charset=utf-8&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$view</span><span class="sy0">-&gt;</span><span class="me1">doctype</span><span class="br0">&#40;</span><span class="st0">&#39;HTML4_STRICT&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$view</span><span class="sy0">-&gt;</span><span class="me1">headMeta</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">-&gt;</span><span class="me1">appendHttpEquiv</span><span class="br0">&#40;</span><span class="st0">&#39;Content-Type&#39;</span><span class="sy0">,</span> <span class="st0">&#39;text/html; charset=UTF-8&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$view</span><span class="sy0">-&gt;</span><span class="me1">xhtmlAllowed</span> <span class="sy0">=</span> <span class="kw2">false</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw3">header</span><span class="br0">&#40;</span><span class="st0">&#39;Content-Type: application/xhtml+xml; charset=utf-8&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re1">$view</span><span class="sy0">-&gt;</span><span class="me1">doctype</span><span class="br0">&#40;</span><span class="st0">&#39;XHTML1_STRICT&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re1">$view</span><span class="sy0">-&gt;</span><span class="me1">headMeta</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">-&gt;</span><span class="me1">appendHttpEquiv</span><span class="br0">&#40;</span><span class="st0">&#39;Content-Type&#39;</span><span class="sy0">,</span> <span class="st0">&#39;application/xhtml+xml; charset=UTF-8&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re1">$view</span><span class="sy0">-&gt;</span><span class="me1">xhtmlAllowed</span> <span class="sy0">=</span> <span class="kw2">true</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>This plugin will serve HTML 4.01 Strict as text/html to IE and XHTML 1.0 Strict as application/xhtml+xml to other browsers.</p>
<p>The only thing you need to do is to register the plugin to the front controller during bootstrapping:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="re1">$frontController</span><span class="sy0">-&gt;</span><span class="me1">registerPlugin</span><span class="br0">&#40;</span><span class="kw2">new</span> My_Controller_Plugin_NegotiateContent<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
<p>And it will take care of content negotiation. The plugin will also set a boolean view variable $view-&gt;xhtmlAllowed so you can use different markups in layouts and views if needed (&lt;img&gt; in HTML and &lt;img /&gt; in XHTML).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.richardknop.com/2010/07/zend-framework-content-negotiation-plugin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Zend Framework IE conditional stylesheets and scripts</title>
		<link>http://blog.richardknop.com/2010/03/zend-framework-ie-conditional-stylesheets-and-scripts/</link>
		<comments>http://blog.richardknop.com/2010/03/zend-framework-ie-conditional-stylesheets-and-scripts/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 21:27:17 +0000</pubDate>
		<dc:creator>Richard Knop</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web design]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[IE conditional comments in Zend Framework]]></category>
		<category><![CDATA[Zend view helpers]]></category>

		<guid isPermaLink="false">http://blog.richardknop.com/?p=559</guid>
		<description><![CDATA[You can append a conditional stylesheet in a controller action like this: $this-&#62;view-&#62;headLink&#40;&#41;-&#62;appendStylesheet&#40;&#39;/path/to/some/styles.css&#39;, &#39;screen&#39;, &#39;IE 8&#39;&#41;; Which would produce this markup: &#60;!--[if IE 8]&#62; &#60;link href="/path/to/some/styles.css" media="screen" rel="stylesheet" type="text/css" /&#62;&#60;![endif]--&#62; Adding a conditional JavaScript file is similar: $this-&#62;view-&#62;headScript&#40;&#41;-&#62;appendFile&#40;&#39;/path/to/some/script.js&#39;, &#39;text/javascript&#39;, array&#40;&#39;conditional&#39; =&#62; &#39;IE&#39;&#41;&#41;; And that would produce markup like this: &#60;!--[if IE]&#62; &#60;script type="text/javascript" src="/path/to/some/script.js"&#62;&#60;/script&#62;&#60;![endif]--&#62; It [...]]]></description>
			<content:encoded><![CDATA[<p>You can append a conditional stylesheet in a controller action like this:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="re1">$this</span><span class="sy0">-&gt;</span><span class="me1">view</span><span class="sy0">-&gt;</span><span class="me1">headLink</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">-&gt;</span><span class="me1">appendStylesheet</span><span class="br0">&#40;</span><span class="st0">&#39;/path/to/some/styles.css&#39;</span><span class="sy0">,</span> <span class="st0">&#39;screen&#39;</span><span class="sy0">,</span> <span class="st0">&#39;IE 8&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
<p>Which would produce this markup:</p>
<pre>&lt;!--[if IE 8]&gt; &lt;link href="/path/to/some/styles.css" media="screen" rel="stylesheet" type="text/css" /&gt;&lt;![endif]--&gt;</pre>
<p>Adding a conditional JavaScript file is similar:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="re1">$this</span><span class="sy0">-&gt;</span><span class="me1">view</span><span class="sy0">-&gt;</span><span class="me1">headScript</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">-&gt;</span><span class="me1">appendFile</span><span class="br0">&#40;</span><span class="st0">&#39;/path/to/some/script.js&#39;</span><span class="sy0">,</span> <span class="st0">&#39;text/javascript&#39;</span><span class="sy0">,</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="st0">&#39;conditional&#39;</span> <span class="sy0">=&gt;</span> <span class="st0">&#39;IE&#39;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
<p>And that would produce markup like this:</p>
<pre>&lt;!--[if IE]&gt; &lt;script type="text/javascript" src="/path/to/some/script.js"&gt;&lt;/script&gt;&lt;![endif]--&gt;</pre>
<p>It can pretty useful when you need to use IE conditional comments just for a single controller action. Otherwise, if it applies site-wide, it&#8217;s better to just put conditional stylesheets and/or scripts in a layout file.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.richardknop.com/2010/03/zend-framework-ie-conditional-stylesheets-and-scripts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rounded corners menu</title>
		<link>http://blog.richardknop.com/2009/05/rounded-corners-menu/</link>
		<comments>http://blog.richardknop.com/2009/05/rounded-corners-menu/#comments</comments>
		<pubDate>Fri, 29 May 2009 14:35:55 +0000</pubDate>
		<dc:creator>Richard Knop</dc:creator>
				<category><![CDATA[Web design]]></category>
		<category><![CDATA[Rounded corners]]></category>

		<guid isPermaLink="false">http://blog.richardknop.com/?p=228</guid>
		<description><![CDATA[Rounded corners menu is very popular in modern designs and it&#8217;s handy to know how to achieve it with a simple CSS applied on a semantic XHTML markup. First, here is the markup: &#60;ul class="rounded"&#62; &#60;li&#62;&#60;a href="#"&#62;&#60;span&#62;Home&#60;/span&#62;&#60;/a&#62;&#60;/li&#62; &#60;li&#62;&#60;a href="#"&#62;&#60;span&#62;About&#60;/span&#62;&#60;/a&#62;&#60;/li&#62; &#60;li&#62;&#60;a href="#"&#62;&#60;span&#62;Services&#60;/span&#62;&#60;/a&#62;&#60;/li&#62; &#60;li&#62;&#60;a href="#"&#62;&#60;span&#62;Portfolio&#60;/span&#62;&#60;/a&#62;&#60;/li&#62; &#60;li&#62;&#60;a href="#"&#62;&#60;span&#62;Contact&#60;/span&#62;&#60;/a&#62;&#60;/li&#62; &#60;li&#62;&#60;a href="#"&#62;&#60;span&#62;Blog&#60;/span&#62;&#60;/a&#62;&#60;/li&#62; &#60;/ul&#62; Quite simple. The only thing that&#8217;s not [...]]]></description>
			<content:encoded><![CDATA[<p>Rounded corners menu is very popular in modern designs and it&#8217;s handy to know how to achieve it with a simple CSS applied on  a semantic XHTML markup. First, here is the markup:</p>
<pre>&lt;ul class="rounded"&gt;
    &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;Home&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;About&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;Services&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;Portfolio&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;Contact&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;Blog&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
<p>Quite simple. The only thing that&#8217;s not right there are span tags &#8211; those are there because it&#8217;s the easiest way to add a hover effect (such as color change) to the rounded menu links.</p>
<p>Here are images I used:</p>
<p><img class="alignnone" title="Left rounded image" src="http://test.richardknop.com/rounded-corners-menu/rounded-left.gif" alt="" width="396" height="43" /></p>
<p><img class="alignnone" title="Right rounded image" src="http://test.richardknop.com/rounded-corners-menu/rounded-right.gif" alt="" width="11" height="43" /></p>
<p>The CSS I used:</p>
<pre>.rounded li {
    display: inline;
}
.rounded a {
    float: left;
    height: 43px;
    margin-right: 1em;
    background: url('rounded-left.gif') left top no-repeat;
    color: white;
    line-height: 43px;
}
.rounded span {
    float: left;
    height: 43px;
    padding: 0 1em;
    background: url('rounded-right.gif') right top no-repeat;
}</pre>
<p>To add the hover effect I used another two images (different only in color):</p>
<p><img class="alignnone" title="Left rounded image hovered" src="http://test.richardknop.com/rounded-corners-menu/rounded-left-hovered.gif" alt="" width="396" height="43" /></p>
<p><img class="alignnone" title="Right rounded image hovered" src="http://test.richardknop.com/rounded-corners-menu/rounded-right-hovered.gif" alt="" width="11" height="43" /></p>
<p>And two additional styles:</p>
<pre>.rounded a:hover {
    background: url('rounded-left-hovered.gif') left top no-repeat;
}
.rounded a:hover span {
    background: url('rounded-right-hovered.gif') right top no-repeat;
}</pre>
<p>Here is the <a href="http://test.richardknop.com/rounded-corners-menu/">demo</a>. Tested in following browsers:</p>
<ul>
<li>IE6, IE7</li>
<li>Firefox</li>
<li>Opera 9.64</li>
<li>Chrome 1.0.154.65</li>
</ul>
<p>You will need to clear the floats after the menu though. I usually do it by adding an additional class to the next element:</p>
<pre>.clear {
    clear: both;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.richardknop.com/2009/05/rounded-corners-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
