Dear @mad ,
first of all I wanted to thank for this wonderful CMS!
It is very slick and truly a pleasure to dive into this system. Nice and clean code structure!
My Question:
I want to style/tweak the dashboard (import custom js- and css-file), depending on the logged in username.
The reason:
I am making a website for my friend (visual artist/sculptor) and I know, that he will be overwhelmed by all the possible variables in the backend. So I wanted to "hide" all the unnecessary options/variables.
I managed this task like this:
The dashboard is being generated from 4 files(footer.php, header.php, navbar.php, sidebar.php) within the folder:
/automad/gui/inc/elements
First I inserted following code right before closing the </head> of the header.php:
<!-- <dashboard-mod by evij> -->
<?php
$user = ucwords(User::get());
if ($user !== "Admin"): ?>
<link href="<?php echo AM_BASE_URL; ?>/packages/dashboard-mod/dashboard-mod.css" rel="stylesheet">
<script type="text/javascript" src="<?php echo AM_BASE_URL; ?>/packages/dashboard-mod/dashboard-mod.js"></script>
<?php else: ?>
<meta name="admin-mode!">
<?php endif ?>
<!-- </dashboard-mod> -->
Basically, I take care of the registered user name.
If this is not "Admin", the "custom styles" are integrated.
My problem now is this:
Both files (JS and CSS) are integrated correctly. The CSS styles are also assigned, but no elements (selected by ID) can be manipulated via JS. Oh, and oddly enough "console.log" is working.
I tried to add a simple class to a block, but it is not appending.
My Code:
`$( document ).ready(function() {
console.log( "ready!" );
$("#am-block-editor-text").addClass("red");
});`
I don't know why it's not working. Is there any active filter in the back to prevent my js being executed?
all the best
evij