Jump to content

Additional CSS for admin templates


mjut
 Share

Recommended Posts

Hello!

I am trying to get some extra css-file into my admin templates. I managed to modify my admin.php to this:

<?php namespace ProcessWire;
	require($config->paths->adminTemplates . 'controller.php'); 
	echo "<link rel='stylesheet' type='text/css' href='" . $config->urls->templates . "css/admin.css'>";

By doing so, the css <link> is added to the very end of each parsed admin-html. (right AFTER the closing </body> tag.)
That causes some trouble. e.g. the page tree is not displaying any more. Although, other pages are working - like the edit form of a page.

My question: is there a correct way of adding my extra css to the admin area?

Thanks for you help!

Stephan

 

Link to comment
Share on other sites

Welcome to the forums @mjut

You need to use $config->scripts->add() for JS and $config->styles->add() for CSS .These need to be added before the controller.php

$config->scripts->add($config->urls->templates . "scripts/admin.js");
$config->styles->add($config->urls->templates . "styles/admin.css");
// this comes last
require($config->paths->adminTemplates . 'controller.php'); 

 

Edited by kongondo
  • Like 6
  • Thanks 1
Link to comment
Share on other sites

Thank you for the input!

@AndZyk that module is amazing. I fiddled around with it for a bit - the number of tweaks is unlimited! I have to save this for other projects. It seems a bit of an overkill for my needs now.

The other approach is exactly what i was looking for! Thank you tons @kongondo - this works like a charm.

Cheers

Stephan

 

  • Like 1
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
 Share

×
×
  • Create New...