<?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>Thijs Lensselink&#039;s Blog &#187; BaseUrl</title>
	<atom:link href="http://lenss.nl/tag/baseurl/feed/" rel="self" type="application/rss+xml" />
	<link>http://lenss.nl</link>
	<description>Webdevelopment and stuff...</description>
	<lastBuildDate>Thu, 26 Apr 2012 21:48:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Zend Framework BaseUrl Helper</title>
		<link>http://lenss.nl/2008/07/zend-framework-baseurl-helper/</link>
		<comments>http://lenss.nl/2008/07/zend-framework-baseurl-helper/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 14:42:36 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[BaseUrl]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://we.designandco.de/?p=19</guid>
		<description><![CDATA[Today i was working with the Zend Framework. And needed the baseUrl to set the correct path for stylesheets and external javascript files. To include stylesheets and javascript files there are methods available in ZF. In your controller you can set: $this-&#62;view-&#62;headLink()-&#62;appendStylesheet('/css/tester.css'); In your view or layout you can then call $this-&#62;headLink(); This works great. [...]]]></description>
			<content:encoded><![CDATA[<p>Today i was working with the <a href="http://framework.zend.com" target="_blank">Zend Framework</a>. And needed the baseUrl to set the correct path for stylesheets and external javascript files. To include stylesheets and javascript files there are methods available in ZF. In your controller you can set:</p>
<pre name="code" class="php">$this-&gt;view-&gt;headLink()-&gt;appendStylesheet('/css/tester.css');</pre>
<p>In your view or layout you can then call</p>
<pre lang="php">$this-&gt;headLink();</pre>
<p>This works great. But the current development structure lacks some good rewrite rules. And having the baseUrl is always a good thing. So i did some searching on Google. To figure out if somebody already has a solution for this problem. After a few minutes i found a post written by <a href="http://www.spotsec.com/blog/archive/2007/12/14/zend-framework-baseurl-view-helper/" target="_blank">Yusak Setiawan</a> from <a href="http://www.zendindonesia.com/" target="_blank">zendindonesia</a> (which is defaced by the way) explaining how to add a placeholder in the bootstrap file. Now this is a good solution. But i like to keep my bootstrap file as clean as possible. So i decided to add a Helper that would do the trick.</p>
<p>Create a file called &#8216;BaseUrl.php&#8217; inside the Helper directory. And fill it with the following code.</p>
<pre name="code" class="php">class Zend_View_Helper_BaseUrl
{
    function baseUrl()
    {
        $base_url = substr($_SERVER['PHP_SELF'], 0, -9);
        return $base_url;
    }
}</pre>
<p>After that it&#8217;s extremly easy to get the baseUrl in your views, layouts or controllers.</p>
<p>Inside the view or layout you can call:</p>
<pre name="code" class="php">$this-&gt;baseUrl();</pre>
<p>And inside the controller you can call it like this.</p>
<pre name="code" class="php">$this-&gt;view-&gt;baseUrl();</pre>
<p><a href="http://blog.motane.lu/2009/01/31/zend-framework-base-url/">Tudor Barbu</a> wrote a great article on this subject.</p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2008/07/zend-framework-baseurl-helper/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
