1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect3 id="zend.view.helpers.initial.baseurl">
4 <title>BaseUrl Helper</title>
7 While most <acronym>URL</acronym>s generated by the framework have the base
8 <acronym>URL</acronym> prepended automatically, developers will need to prepend the
9 base <acronym>URL</acronym> to their own <acronym>URL</acronym>s in order for paths
10 to resources to be correct.
14 Usage of the BaseUrl helper is very straightforward:
17 <programlisting language="php"><![CDATA[
19 * The following assume that the base URL of the page/application is "/mypage".
24 * <base href="/mypage/" />
26 <base href="<?php echo $this->baseUrl(); ?>" />
30 * <link rel="stylesheet" type="text/css" href="/mypage/css/base.css" />
32 <link rel="stylesheet" type="text/css"
33 href="<?php echo $this->baseUrl('css/base.css'); ?>" />
38 For simplicity's sake, we strip out the entry <acronym>PHP</acronym> file (e.g.,
39 "<filename>index.php</filename>") from the base <acronym>URL</acronym> that was
40 contained in <classname>Zend_Controller</classname>. However, in some situations
41 this may cause a problem. If one occurs, use
42 <methodname>$this->getHelper('BaseUrl')->setBaseUrl()</methodname> to set your