cakephpcakephp-2.0cakephp-2.xcakephp-2.6

CakePHP HTMLHelper for Scripts uses extra param in URL causing scripts not to load


For our project we've been using a lot of subdomains, but for one particular section we just use a redirect that sends the user of a specific type from the normal dashboard at /dashboard to /manager/dashboard.

This has been in place for months and works, but now in an element within our view we're trying to load some scripts using the HTMLHelper, but it's appending the /manager to the URL.

How can I have it just access the webroot version at

/js/path 

instead of

/manager/js/path

using a generic element that is used throughout our application in different subdomains like it doesn't now (with the exception of /manager/*?


Solution

  • Try adding

    Configure::write('App.jsBaseUrl','js/');
    

    to your bootstrap.php file.

    Alternatively, if you provide the full path to the .js file (starting with a leading /), CakePHP will ignore whatever App.jsBaseUrl holds, and will render the correct path.