Search code examples
phphtmlzend-framework2

Zend HTML Link to file above $baseUrl


I am trying to create an html link in the head section of a page, to a /node_modules/ file which is outside of the /public directory. The $baseUrl is /public.

How can i create a link to a file which is not in the /public directory?

I have tried the usual relative path (../) but obviously this does not work and php is required to solve this.

The directory structure is as follows:-

/siteroot    
    /node_modules/
    /public

Example current link:-

<?php echo $baseUrl; ?>/node_modules/jquery-ui-timepicker-addon/dist/jquery-ui-timepicker-addon.css">

but this will look for /node_modules/ inside of public, which is not whats required.


Solution

  • You can use getcwd(), this will return a path to project directory, i.e "/siteroot", as current working directory.

    So now you can use it as

    <?php echo getcwd(); ?>/node_modules/jquery-ui-timepicker-addon/dist/jquery-ui-timepicker-addon.css">