2

i put this code in bootstrap file

//product category url managment
    $defaults = array('controller'=>'productcat' , 'action'=>'catinfo' );
    $productRoute = new Zend_Controller_Router_Route('productcat/:id/:title', $defaults);
    $router = $frontController->getRouter();
    $router->addRoute("productcat", $productRoute);

and i put this code in one of phtml files (in layout)

<a href="<?php echo $this->url(array( "controller"=>"aboutus" , "action"=>"index"));  ?>">about us</a>

but when i`m in a url like this :

http://quickstart.local/donyaye_fan_zend/public/ every things is ok. if i go to url like this: http://quickstart.local/donyaye_fan_zend/public/productcat/1/sample

link for aboutus dont work and it show current page url in href!!!

what is the reason?!

2 Answers 2

4

You should specify default route to use. Try this:

<a href="<?php echo $this->url(array( "controller"=>"aboutus" , "action"=>"index"), 'default');  ?>">about us</a>

If it will not help, then try to reset the route with:

<a href="<?php echo $this->url(array( "controller"=>"aboutus" , "action"=>"index"), 'default', true);  ?>">about us</a>
Sign up to request clarification or add additional context in comments.

1 Comment

I ran into this issue today, can you explain why this works but using null as router does not? It works fine for all links in my website, except for one and I don't understand why.
2

In case of different routes is better to specify the route "default" for each link that use no custom routes.

so:

<a href="<?php echo $this->url(array( "controller"=>"aboutus" , "action"=>"index", "route"=>"default"));  ?>">about us</a>

should work

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.