开发者

Zend : Setting paths

While building a project and linking the pages together within that project, It has come to my attention that to link things together, I have to set the path as follows :

/projectname/public/controllername

Now when I move this from my local machine across to a live site, I ideally dont need or want the /projectname/public paths to display. Or have to go through and clear 开发者_StackOverflowthem from the application.

This is going to be quite an issue, particularly with forms where the action is set to "/projectname/public/controller/action"

Does anyone know what is best to replace the first parts of my links with? Or am I looking at .htaccess to cover this

Thanks in advance.


You should be using the Url and BaseUrl helpers for all internal controller URLS and static asset (images, JS, etc) URLs respectively.

For example

<!-- Link to controller "Foo", action "bar" -->
<a href="<?php echo $this->url(array(
    'controller' => 'foo',
    'action'     => 'bar',
    'param'      => 'value')) ?>">Go to FooController::barAction()</a>

<img src="<?php echo $this->baseUrl('images/baz.png') ?>">

Example layout file entry using the headLink helper...

<?php echo $this->headLink($this->baseUrl('css/stylesheet.css')) ?>

Using these helpers makes your application portable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜