PWaddict Posted February 12, 2017 Posted February 12, 2017 2 hours ago, Martijn Geerts said: @PWaddict, do you use the dependencies or the default injection method? I tried both. The default one injects a broken link as I described above and the dependencies doesn't inject anything.
bernhard Posted February 12, 2017 Posted February 12, 2017 i think it's more related to setting up a proper rewrite base than changing this module. https://processwire.com/docs/tutorials/troubleshooting-guide/page3
PWaddict Posted February 12, 2017 Posted February 12, 2017 1 hour ago, bernhard said: i think it's more related to setting up a proper rewrite base than changing this module. https://processwire.com/docs/tutorials/troubleshooting-guide/page3 I'm not sure cause every other link on ProcessWire works great except the link injection in this module. On the AdminCustomFiles.module I replaced the 249 line: 'relative' => substr($base, strpos($base, '/site/templates/')), to this and it worked: 'relative' => substr($base, strpos($base, '/mysite.com/site/templates/')), It seems that the module can't recognize that ProccessWire installed on localhost/mysite.com. 1
Peejay Posted April 13, 2017 Posted April 13, 2017 Hi, I only see the changes of my css file (templates/AdminCustomFiles/AdminThemeReno.css) when I'm logged-in as superuser, when I have an other roll I just see the default AdminThemeReno. Does anyone know what I'm doing wrong? *working with version: 3.0.59
Martijn Geerts Posted April 14, 2017 Author Posted April 14, 2017 Hee PeeJay, I will see if I have time soon and if I can reproduce and fix it. Thanks for the report. 2
Macrura Posted April 16, 2017 Posted April 16, 2017 for some reason the 'include theme based files' stopped working, so i added AdminCustomFiles/AdminThemeReno.css to the dependencies, and it works.. @Peejay that might solve your problem... 1
Martijn Geerts Posted April 18, 2017 Author Posted April 18, 2017 @Peejay there are some more little improvements coming up but there are still a few annoyances. But there will be updates soon, sorry guys for the delays, but free time is sparse these days. 3
Robin S Posted May 29, 2017 Posted May 29, 2017 Hi @Martijn Geerts, just a heads up that the current version number of this module is 0.0.1 - is that supposed to be 1.0.0? Because I've just noticed that the version I have been running is 0.8.7 which is older than the current version yet I never get an upgrade prompt in the Upgrades module due to the low current version number. Also, did you change GitHub repos at some point? There seems to be only a few months of commit history yet the module has been around much longer than that.
PWaddict Posted October 28, 2017 Posted October 28, 2017 I'm trying to inject a custom js for AdminThemeUikit but it loads before the original AdminThemeUikit js files. How to make it load after the original files?
Martijn Geerts Posted October 29, 2017 Author Posted October 29, 2017 Hi PWaddict, I see. There're changes in the way themes are handled. I gonna investigate.
Martijn Geerts Posted October 29, 2017 Author Posted October 29, 2017 @PWaddict Thanks for your report, I've added an extra hook (after AdminTheme::getExtraMarkup) and updated the version number. Changes are uploaded to GitHub. https://github.com/Da-Fecto/AdminCustomFiles 1
PWaddict Posted October 29, 2017 Posted October 29, 2017 40 minutes ago, Martijn Geerts said: @PWaddict Thanks for your report, I've added an extra hook (after AdminTheme::getExtraMarkup) and updated the version number. Changes are uploaded to GitHub. https://github.com/Da-Fecto/AdminCustomFiles My custom js for AdminThemeUikit is still loading before the original files. This is happening only for js. The custom css loads properly.
Martijn Geerts Posted October 29, 2017 Author Posted October 29, 2017 @PWaddict I think i'm locked in... don't know how to solve this one. $config->scripts and $config->styles are echoed before those admin scripts are echoed. I don't know what I can do about that.
PWaddict Posted October 29, 2017 Posted October 29, 2017 1 hour ago, Martijn Geerts said: @PWaddict I think i'm locked in... don't know how to solve this one. $config->scripts and $config->styles are echoed before those admin scripts are echoed. I don't know what I can do about that. Here is the css & js structure with the AdminThemeDefault: and here is with the AdminThemeUikit: So maybe it needs an extra hook that is specific to AdminThemeUikit in order for the files to be injected at the very end
cstevensjr Posted October 29, 2017 Posted October 29, 2017 On 10/28/2017 at 8:54 AM, PWaddict said: I'm trying to inject a custom js for AdminThemeUikit but it loads before the original AdminThemeUikit js files. How to make it load after the original files? Maybe I'm looking at this wrong, but you should physically list the AdminThemeUikitCustom.js after all the uikit js in whatever template file you are using.
bernhard Posted October 29, 2017 Posted October 29, 2017 You can also inject scripts and styles by hooking the page render and doing a str_replace("</head>", $yourscripts . "</head>", $event->return) 4
PWaddict Posted October 29, 2017 Posted October 29, 2017 48 minutes ago, bernhard said: You can also inject scripts and styles by hooking the page render and doing a str_replace("</head>", $yourscripts . "</head>", $event->return) Is it possible to do this on site/ready.php without creating a module?
bernhard Posted October 29, 2017 Posted October 29, 2017 Sure, just hook page render and modify event->return like I showed above. I'm on mobile but this info is easy to find in the forum, it's nothing special
Martijn Geerts Posted October 29, 2017 Author Posted October 29, 2017 Thanks @bernhard, think I will rty that route. Hopefully have some spare time this week to manage that.
PWaddict Posted October 29, 2017 Posted October 29, 2017 @bernhard Here is the code I used on site/ready.php and it works great: if($this->page->template == 'admin') { $this->addHookAfter('Page::render', function($event) { $css = wire('config')->urls->templates . 'styles/AdminThemeUikit.css?v=1'; $js = wire('config')->urls->templates . 'scripts/AdminThemeUikit.js?v=1'; $event->return = str_replace("</head>", "\n<link type='text/css' href='{$css}' rel='stylesheet'/>\n</head>", $event->return); $event->return = str_replace("</body>", "\n<script type='text/javascript' src='{$js}'></script>\n</body>", $event->return); }); }; I've also uninstalled Admin Custom Files since I was only using it to inject theme files. Thank you. 4
bernhard Posted October 29, 2017 Posted October 29, 2017 never used it but you could save another line with conditional hooks https://processwire.com/blog/posts/new-ajax-driven-inputs-conditional-hooks-template-family-settings-and-more/#new-conditional-hooks $wire->addHookAfter('Page(template=admin)::render', function($event) { ... }); 2
Robin S Posted October 29, 2017 Posted October 29, 2017 Another option for adding elements at the end of <head>: $wire->addHookAfter('AdminTheme::getExtraMarkup', function(HookEvent $event) { $parts = $event->return; $parts['head'] .= "<script src='/path/to/script.js'></script>"; $event->return = $parts; }); 5
tpr Posted October 30, 2017 Posted October 30, 2017 Or you can load a JS loader that loads your JS. 2
matjazp Posted November 1, 2017 Posted November 1, 2017 @Martijn Geerts I upgraded from 0.8.7 to 0.9.4 and I get: Warning: Invalid argument supplied for foreach() in C:\inetpub\wwwroot\site\modules\AdminCustomFiles\AdminCustomFiles.module on line 249 $files = NULL $dependencies = string(41) "ProcessPageEdit AdminCustomFiles/test.css" Also, AdminCustomFiles.js fails at line 19. I see that you dropped support for PW 2. Any reason for that?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now