Ionut Cioarec
Ionut Cioarec

Reputation: 3

Cakephp 3 problems accesing non plugin links from plugin pages

I have a cakephp app and I created a plugin based on cakephp 3.8 official documentation. Everything is good, I can access links like:

project.local/plugin/plugin-tests/

. The problem is that after I access that plugin link, all my links are updated with the plugin name. Eg: project.local/users/ is transformed into project.local/plugin/users/.

Upvotes: 0

Views: 87

Answers (1)

ndm
ndm

Reputation: 60463

The values for plugin, prefix, controller and action are being persisted by default, meaning that if you don't specify them explicitly in your URL arrays, they inherit the value of the current context.

If you want your links to always point to a non-plugin target, make sure to set null for it, likewise set false for the prefix (not null), ie:

[
    'plugin' => null, // break out of plugin contexts
    'prefix' => false, // break out of prefix contexts
    'controller' => 'Users',
    'action' => 'index',
]

See also

Upvotes: 1

Related Questions