Zend_View-Helpers-BaseUrl.xml 1.5 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 <acronym>URL</acronym>s generated by the framework have the base
  7. <acronym>URL</acronym> prepended automatically, developers will need to prepend the
  8. base <acronym>URL</acronym> to their own <acronym>URL</acronym>s in order for paths
  9. to resources to be correct.
  10. </para>
  11. <para>
  12. Usage of the BaseUrl helper is very straightforward:
  13. </para>
  14. <programlisting language="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 <acronym>PHP</acronym> file (e.g.,
  33. "<filename>index.php</filename>") from the base <acronym>URL</acronym> that was
  34. contained in <classname>Zend_Controller</classname>. However, in some situations
  35. this may cause a problem. If one occurs, use
  36. <methodname>$this->getHelper('BaseUrl')->setBaseUrl()</methodname> to set your
  37. own BaseUrl.
  38. </para>
  39. </note>
  40. </sect3>