This forum is for assistance with theme development.

How to add JavaScript function to theme?

Hi,

I created a subtheme recently and I'm trying to add a JavaScript function, which toggles on and off the visibility of the main navigation menu.

In my theme, I created a JavaScript file and added my function:

hook_theme is it still allowed in Drupal 10

hi,

hook_theme is it still allowed in Drupal 10 ?

if not, what should be done to use the templates.html.twig ?

Thanxs


css load order

I have the following theme hierarchy

A <-- B <-- C

Essentially the theme B inherits from the theme A and the theme C (that I develop) inherits from theme B.

Then, at a certain time I've realized that some CSS files provided by the theme B are included after the files provided by my theme (theme C) in this way overwriting my styles. Instead I would like exactly the opposite to happen: I want to overwrite some styles provided by the theme B in my theme C.

Theme changes not being reflected on website

Hi,

I created a local Drupal 10 site using ddev and Docker Desktop, and then I created a subtheme using drush:

ddev drush generate theme

But for some reason, once I wrote my CSS files, none of the CSS changes are being reflected on the website. The website is frozen with the default look of the subtheme (before I made my CSS changes).

Any ideas on why this might be happening?

Adding new css class to generated theme in Drupal 10

I have generated a new theme in Drupal 10 and am now modifying twig files. I have created a page--front.html.twig file from page.html.twig and am now making modifications to it. As part of the modifications, I want to change the css class layout-content to have a background color and thus replaced occurrences of layout-content with my-layout-content in this twig.html file

Change content link attributes - hook

Hi

I'm trying to change all occurrences of target="_blank" in my site's content but when using the link_alter hook it only seems to effect the admin menu.
Which hook should I use?

What I've tried

function MYNAME_module_link_alter(&$variables) {
 if (isset($variables['options']['attributes']['target']) && $variables['options']['attributes']['target'] == '_blank') {
  $variables['options']['attributes']['target'] = '_self';
}
}

Thanks

Pages

Subscribe with RSS Subscribe to RSS - Theme development