Skip to content

kdouglass/craft-cpjs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Control Panel JS plugin for Craft CMS

Easily insert additional JavaScript into the Craft Control Panel.


This version is for Craft 3. To install it, visit the Plugin Store in your site's Control Panel.

For the Craft 2 version, see the v1 branch...


After you've installed the plugin, go to:

  • Settings > Plugins > Control Panel JS

Your custom JavaScript can be saved in either (or both) of two places:

1) An external file in your public directory...

2) The "Additional JavaScript" field on the settings page...

You can customize your JavaScript in any way you see fit!


Environment-aware file path

If you'd like to set your JavaScript file path at the environment level, then you'll simply want to create a /config/cp-js.php file, and enter something like this...

return [
    '*' => [],
    'dev' => [
        'jsFile' => 'http://local.dev/path/to/cp.js',
    ],
    'production' => [
        'jsFile' => 'http://example.com/path/to/cp.js',
    ]
];

You can also keep the file path out of your repo entirely, by using .env variables to set the JS file path...

return [
    'jsFile' => getenv('CP_JS_FILE'),
];

With that in place, you can add this to your .env file...

# Path to JS file for the Control Panel
CP_JS_FILE="http://example.com/path/to/cp.js"

Anything else?

We've got other plugins too!

Check out the full catalog at doublesecretagency.com/plugins

About

Control Panel JS plugin for Craft CMS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • CSS 60.2%
  • PHP 32.1%
  • HTML 6.1%
  • JavaScript 1.6%