StuBlackett
StuBlackett

Reputation: 3857

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 them 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.

Upvotes: 0

Views: 39

Answers (1)

Phil
Phil

Reputation: 164732

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.

Upvotes: 1

Related Questions