views:

29

answers:

2

in zend framework, i usually setup vhosts so that i can refer to my static resources like js, css via "/css/styles.css" but what if i dont setup vhosts? my path to the static resources will be like "http://localhost/app1/css/styles.css". is there a way to find find what is the proper path to css/styles.css without hardcoding the "prefix" http://localhost/app1/? if done properly, i shld be able to move my app from http://localhost/app1 to http://localhost/a/deeper/path/app2/

A: 
<?php echo $this->headLink()->appendStylesheet('/css/global.css') ?>

is how I set mine up. Make sure the appropriate corresponding paths are set in the index.php and config.ini. See the Zend Framework quickstart for more information if necessary.

bpeterson76
thats how i set mine too. but that will only work if u setup `vhosts` if u didnt, and the url of your app looks like `http://localhost/some/path/zf/public`, the css will point to `http://localhost/css/global.css` which is wrong. i know that in production, url wont look like this but i am currently developing, and maynot want to setup vhosts
jiewmeng
+3  A: 

You need the BaseUrl View-Helper

<?php echo $this->headLink()->appendStylesheet($this->baseUrl('/css/global.css')) ?>
Benjamin Cremer