Skip to content

Please load admin.js automatically in the backend #552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BernhardBaumrock opened this issue Jan 5, 2025 · 3 comments
Closed

Please load admin.js automatically in the backend #552

BernhardBaumrock opened this issue Jan 5, 2025 · 3 comments

Comments

@BernhardBaumrock
Copy link

ProcessWire already loads the following files in the backend

  • /site/templates/admin.php
  • /site/templates/admin.less

It would be great if it could also load

  • /site/templates/admin.js

automatically for all kinds of backend javascript modifications where it would be overkill to create an autoload module that loads those stylesheets.

@jmartsch
Copy link

jmartsch commented Jan 5, 2025

If this is considered to be implemented, please also use the type='module' attribute, so we can use ES6 module imports.

@jlahijani
Copy link

jlahijani commented Jun 6, 2025

I like this idea but I wonder about what the default path would be for admin.js for example. Personally I put all admin related things in /site/templates/admin/ as to me /site/templates/ without a subdir is more frontend and php specific.

But at the same time if you look at it another way, it does follow ProcessWire conventions that a .php and .js file would be in the same directory (ie /site/templates/admin.php which is the default admin file, meaning admin.js should stay in /site/templates/).

I suppose having the path be configurable would be recommended (similar to $config->AdminThemeUikit).

@BernhardBaumrock
Copy link
Author

@jlahijani I'm closing this as Ryan mentioned he tries to avoid any additional file_exists() checks as much as possible.

I think the easiest approach is to add one line to admin.php in case one needs to load an admin.js file:

$config->scripts->add('/site/templates/admin.js');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants