Search code examples
phpmodel-view-controllerweblithium

How to get base URL in a Lithium template/view?


I want to access a folder named 'Videos'. It is placed parallel to images/scripts etc. I can send the base url in a variable from the controller but it doesn't make sense. Is there a way I can access the folder in a template/view?


Solution

  • To generate a base URL, you can do $this->url("/"), but for paths to assets, there's $this->path("/"), which hooks into the Media class. Often these values will be the same, but Media allows you to have more sophisticated asset configurations, and path() keeps your generated paths in sync with it.