Zend_View-Helpers-BaseUrl.xml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect3 id="zend.view.helpers.initial.baseurl">
  4. <title>BaseUrl Helper</title>
  5. <para>
  6. While most URLs generated by the framework have the base URL
  7. prepended automatically, developers will need to prepend the
  8. base URL to their own URLs in order for paths to resources to
  9. be correct.
  10. </para>
  11. <para>
  12. Usage of the BaseUrl helper is very straightforward:
  13. </para>
  14. <programlisting role="php"><![CDATA[
  15. /*
  16. * The following assume that the base URL of the page/application is "/mypage".
  17. */
  18. /*
  19. * Prints:
  20. * <base href="/mypage/" />
  21. */
  22. <base href="<?php echo $this->baseUrl(); ?>" />
  23. /*
  24. * Prints:
  25. * <link rel="stylesheet" type="text/css" href="/mypage/css/base.css" />
  26. */
  27. <link rel="stylesheet" type="text/css"
  28. href="<?php echo $this->baseUrl('css/base.css'); ?>" />
  29. ]]></programlisting>
  30. <note>
  31. <para>
  32. For simplicity's sake, we strip out the entry PHP file (e.g.,
  33. "index.php") from the base URL that was contained in
  34. <classname>Zend_Controller</classname>. However, in some situations
  35. this may cause a problem. If one occurs, use
  36. <code>$this->getHelper('BaseUrl')->setBaseUrl()</code> to set your
  37. own BaseUrl.
  38. </para>
  39. </note>
  40. </sect3>