1

I have a common layout with a button for opening a specific page :

<?php echo $this->Html->link('My cart', array('controller' => 'shop', 'action' => 'cart'), array('escape' => false)) ?>

This link will redirect to a page /shop/cart . But if I'm in a page using another controller I have a problem. Example : I'm on a page depending on UsersController, my URL is : customer/ and now if I'm clicking on 'My Cart' link, URL is : customer/shop/cart which is an error.

How can I clear my URL?

Thanks.

Inigo Flores
  • 4,461
  • 1
  • 15
  • 36
Ty Yt
  • 466
  • 2
  • 9
  • 25

1 Answers1

2

You have probably set customer as a routing prefix in /Config/core.php:

Configure::write('Routing.prefixes', array('customer'));

and you are linking to /shop/cart from within an action that starts with customer_.

This is the default behavior.

To remove the prefix, rewrite the link as follows:

<?php echo $this->Html->link('My cart', array('controller' => 'shop', 'action' => 'cart','customer'=>false), array('escape' => false)) ?>

More on Prefix Routing.

Inigo Flores
  • 4,461
  • 1
  • 15
  • 36