I have a problem with a custom theme I created on a Drupal 9 test site:
- Drupal version: 9.3.13
- Web server Apache 2.4.41 (xampp win64)
- PHP version 8.0.11
- Database version 10.4.8-MariaDB
custom theme professional.info.yml:
name: Professional type: theme description: Drupal 9 version of Professional theme core_version_requirement: ^8 || ^9 base theme: false version: 1.0.0 libraries: - professional/global-styling - professional/global-scripts regions: sidebar_first: 'First Sidebar' sidebar_second: 'Second Sidebar' header: 'Header' front_welcome: 'Front Welcome' content: 'Content' content_top: 'Content Top' help: 'Help' footer: 'Footer' footer_first: 'First Bottom' footer_second: 'Second Bottom' footer_third: 'Third Bottom' features: logo: true site_name: true site_slogan: true node_user_picture: true comment_user_picture: true comment_user_verification: true favicon: true main_menu: true secondary_menu: false
custom theme professional.libraries.yml:
global-styling: version: VERSION css: theme: css/style.css: {} global-scripts: version: VERSION js: js/custom.js: {} js/jquery.flexslider-min.js: {} js/slide.js: {} dependencies: - core/jquery - core/drupal - core/drupalSettings - core/drupal.dialog.ajax
I saved all the files of the new theme respecting the convention:
/site-root —->/themes/professional —-> /css —-> /js —-> /templates/system
but the problem is that the dependencies like "- core/drupal" are not applied at all and even the three custom js files in "global-scripts" directive are not included in the site pages, but on the opposite both the css files of Drupal core and the custom "style.css" are included. I saw that on the chrome browser development tools console when I tried for example to show a basic page node in a modal popup using a drupal.org example:
<ol> <li><a class="use-ajax" data-dialog-options="{"width":400}" data-dialog-type="modal" href="/xampp/drupal9test/node/9">Basic page displayed in modal dialog. </a></li> <li><a class="use-ajax" data-dialog-options="{"width":400}" data-dialog-type="dialog" href="/xampp/drupal9test/node/9">Basic page displayed in non modal dialog. </a></li> <li><a class="edit-button use-ajax" data-dialog-options="{"width":400}" data-dialog-renderer="off_canvas" data-dialog-type="dialog" href="/xampp/drupal9test/node/9">Basic page displayed in a nice off canvas dialog. </a></li> </ol>
The node is shown as a conventional page, no modal popup is open. So neither core js nor ajax is applied if I use my custom theme, if I switch to Bartik theme everything is working, modals too. I tried adding drupal core and ajax libraries directly in the professional_preprocess_page(&$variables) in the professional.theme file with the line:
$variables['#attached']['library'][] = 'core/drupal'; $variables['#attached']['library'][] = 'professional/global-scripts';
and I even tried to add libraries with twig directly in template html.html.twig like {{ attach_library(‘core/drupal’) }} or any other libraries etc…
but none of these changes did have any effect.
Of course every time I changed som settings I cleared the site cache.
So my question is what am I doing wrong? Can someone give me a solution?