Jump to content

Admin Custom Files


Martijn Geerts

Recommended Posts

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.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

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

Link to comment
Share on other sites

  • 1 month later...

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.

Link to comment
Share on other sites

  • 4 months later...
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.

Link to comment
Share on other sites

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:

AdminThemeDefault.thumb.jpg.6cd90dc94f6e63fa3f0f8eae986d6a35.jpg

and here is with the AdminThemeUikit:

AdminThemeUikit.thumb.jpg.8b97c2fb0eeec0964f4cbf28e1b7fca1.jpg

So maybe it needs an extra hook that is specific to AdminThemeUikit in order for the files to be injected at the very end???

Link to comment
Share on other sites

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?

AdminThemeUikitJS.thumb.jpg.d2340e4b691b7b70c047edc56d3fd5a4.jpg 

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.

Link to comment
Share on other sites

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

  • Like 4
Link to comment
Share on other sites

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;
});

 

  • Like 5
Link to comment
Share on other sites

@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?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...