PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, March 13, 2022

[FIXED] Cakephp 3 problems accesing non plugin links from plugin pages

 March 13, 2022     cakephp, cakephp-3.x, plugins     No comments   

Issue

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


Solution

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

  • Cookbook > Routing > Creating Links to Plugin Routes
  • Cookbook > Routing > Prefix Routing


Answered By - ndm
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing