0

I created a template.php file, put the following function inside, saved, and flushed all Drupal cache. The desired change didn't occur.

function garku_process_html(&$variables) {
  $variables['styles'] = preg_replace('/.css\?.*"/','.css"', $variables['styles']);
}

How should I declare the usage of a new template.php file in a Drupal 8 sub-theme?

I ask since I haven't found anything about this in the documentation, for example in Overview of theme files.

5

Drupal 8 themes don't have template.php files. Now they use a mytheme.theme file, which needs to be located inside the directory containing the theme. (Replace mytheme with the machine name used by the theme.)

Preprocessing and modifying attributes in a .theme file shows an example of preprocess function, which is placed in the mytheme.theme file, instead of the template.php file.

3

The file name was changed to [theme-name].theme; from the docs:

*.theme

The .theme file is a PHP file that contains all the conditional logic and data (pre)processing of the output. It may also extend basic theme settings.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy