Sorry I should have mentioned this also. In my bootstrap I manually set the
base url of my application using the instance of my front controller. I'm
not positive but I presume once the base url property is set correctly in
your front controller Zend View will inherit your application path.

 

$frontController->setBaseUrl(APP_PATH);

 

$view->baseUrl = $frontController->getBaseUrl();

 

Hope this helps.

 

Thomas Shaw

[email protected]

[email protected]

 

 

From: holografix . [mailto:[email protected]] 
Sent: Thursday, March 26, 2009 9:52 AM
To: [email protected]
Subject: [fw-general] Zend_View / Layout paths problem

 

Hi

I am facing a problem with paths and don't know how to solve it.
Everything works fine except that the css file it is not loaded and the
output it is plain text without images and columns.

My developing box is a Windows Vista 32 with a typical wamp stack:
Apache 2.2.11, PHP 5.2.9, ZF 1.7.7

Apache httpd.conf

NameVirtualHost *

<VirtualHost *>
    ServerName myapp
    DocumentRoot "c:/wwwroot/www-php/myapp/public/"

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ /index.php [NC,L]
</VirtualHost>


<VirtualHost *>
    ServerName localhost
    DocumentRoot "c:/wwwroot/www-php"
</VirtualHost>


Windows hosts file

127.0.0.1  myapp
127.0.0.1  localhost


Bootstrap.php

define('APPLICATION_PATH', realpath(dirname(__FILE__) .
'/../application/'));

$frontController = Zend_Controller_Front::getInstance();
$frontController->setControllerDirectory('../application/controllers');
$frontController->setParam('env', 'development');

$view = new Zend_View();
$view->addHelperPath('../application/views/helpers');
$view->doctype('XHTML1_STRICT');
$view->headTitle()->setSeparator(' - ')->append('ZF Test');
$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;
charset=utf-8');
$view->headLink()->appendStylesheet('/css/style.css');
//$view->headLink()->appendStylesheet('css/style.css');

$viewRenderer =
Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRenderer->setView($view);

Zend_Layout::startMvc(array('layoutPath' => APPLICATION_PATH .
'/layouts/scripts'));

 

layout.phtml

<?php echo $this->doctype(); ?>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<?php
echo $this->headTitle();
echo $this->headLink();
echo $this->headStyle();
?>
</head>
<body class="twoColElsLtHdr">
    <div id="container">
        <div id="header">
            Header <img src="/images/logo.jpg" />
        </div><!-- end #header -->
        <div id="sidebar1">
            <h3>sidebar1 Content</h3>
            <p>The background color on this div will only show for the
length of the content. If you'd like a dividing
            line instead, place a border on the left side of the
#mainContent div if the #mainContent div will always contain
            more content than the #sidebar1 div. </p>
            <p>Donec eu mi sed turpis feugiat feugiat. Integer turpis arcu,
pellentesque  eget, cursus et, fermentum ut, sapien. </p>
        </div><!-- end #sidebar1 -->
        <div id="mainContent">

            <?php echo $this->layout()->content ?>

        </div><!-- end #mainContent -->
        <!-- This clearing element should immediately follow the
#mainContent div in order to force the #container div to contain all child
floats --><br class="clearfloat" />
        <div id="footer">
            <p>Footer</p>
        </div><!-- end #footer -->
    </div><!-- end #container -->

</body>
</html>


Generated html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<title>ZF Test</title>
<link href="/css/style.css" media="screen" rel="stylesheet" type="text/css"
/></head>
<body class="twoColElsLtHdr">
    <div id="container">
        <div id="header">
            Header <img src="/images/logo.jpg" />
        </div><!-- end #header -->
        <div id="sidebar1">
            <h3>sidebar1 Content</h3>

            <p>The background color on this div will only show for the
length of the content. If you'd like a dividing line instead,
            place a border on the left side of the #mainContent div if the
#mainContent div will always contain more content than the #sidebar1 div.
</p>
            <p>Donec eu mi sed turpis feugiat feugiat. Integer turpis arcu,
pellentesque  eget, cursus et, fermentum ut, sapien. </p>
        </div><!-- end #sidebar1 -->
        <div id="mainContent">

            Hello from the index view script.<br /><br />

        </div><!-- end #mainContent -->

        <!-- This clearing element should immediately follow the
#mainContent div in order to force the #container div to contain all child
floats --><br class="clearfloat" />
        <div id="footer">
            <p>Footer</p>
        </div><!-- end #footer -->
    </div><!-- end #container -->

</body>
</html>

Some info from print_r($_SERVER) in index.php
[SCRIPT_URL] => /
[SCRIPT_URI] => http://myapp/
[HTTP_HOST] => myapp
[SERVER_NAME] => myapp
[SERVER_ADDR] => 127.0.0.1
[SERVER_PORT] => 80
[DOCUMENT_ROOT] => C:/wwwroot/www-php/myapp/public/
[SERVER_ADMIN] => @@ServerAdmin@@[SCRIPT_FILENAME] =>
C:/wwwroot/www-php/myapp/public/index.php
[REQUEST_URI] => /
[SCRIPT_NAME] => /index.php
[PHP_SELF] => /index.php

echo APPLICATION_PATH; => C:\wwwroot\www-php\myapp\application


Sorry for this long message but I really need some help to figure out what I
am doing wrong.
Thanks in advance.

Cheers,
holo

Reply via email to