File: Zend_View-Helpers-BaseUrl.xml

package info (click to toggle)
zendframework 1.12.9%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 133,584 kB
  • sloc: xml: 1,311,829; php: 570,173; sh: 170; makefile: 125; sql: 121
file content (46 lines) | stat: -rw-r--r-- 1,511 bytes parent folder | download | duplicates (2)
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
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect3 id="zend.view.helpers.initial.baseurl">
    <title>BaseUrl Helper</title>

    <para>
        While most <acronym>URL</acronym>s generated by the framework have the base
        <acronym>URL</acronym> prepended automatically, developers will need to prepend the
        base <acronym>URL</acronym> to their own <acronym>URL</acronym>s in order for paths
        to resources to be correct.
    </para>

    <para>
        Usage of the BaseUrl helper is very straightforward:
    </para>

    <programlisting language="php"><![CDATA[
/*
 * The following assume that the base URL of the page/application is "/mypage".
 */

/*
 * Prints:
 * <base href="/mypage/" />
 */
<base href="<?php echo $this->baseUrl(); ?>" />

/*
 * Prints:
 * <link rel="stylesheet" type="text/css" href="/mypage/css/base.css" />
 */
<link rel="stylesheet" type="text/css"
     href="<?php echo $this->baseUrl('css/base.css'); ?>" />
]]></programlisting>

    <note>
        <para>
            For simplicity's sake, we strip out the entry <acronym>PHP</acronym> file (e.g.,
            "<filename>index.php</filename>") from the base <acronym>URL</acronym> that was
            contained in <classname>Zend_Controller</classname>. However, in some situations
            this may cause a problem. If one occurs, use
            <methodname>$this->getHelper('BaseUrl')->setBaseUrl()</methodname> to set your
            own BaseUrl.
        </para>
    </note>
</sect3>