Drupal 10 with Groups Module.
I have a Group with a field, field_custom_css. This field is a long formatted text area that is using Ace Editor. The user inputs CSS into this field.
In my theme, I'm using hook_preprocess_page()
, like so:
if (($group = \Drupal::routeMatch()->getParameter('group'))) {
$custom_css = $group->get('field_custom_css')->value;
if ($custom_css) {
$variables['#attached']['html_head'][] = [
[
'#tag' => 'style',
'#attributes' => [
'id' => 'course-css',
],
'#value' => $custom_css,
],
'course___css',
];
}
}
This works, but it loads the CSS above all the other CSS in the <head>
. This means that, unless I use !important
for everything, I cannot easily override styling using this field.
I would like to load the CSS very last.
I've tried using $variables['page']['#attached']['html_head'][]
, but this doesn't add css to the <head>
at all.
I've also tried using #weight
, but that has no affect.
I would like course___css
to be the very last thing that gets loaded into the <head>
, or perhaps even gets attached to the body instead.