Subtheme: Update documentation around subtheming

Created on 14 November 2023, about 1 year ago
Updated 15 November 2023, about 1 year ago

Problem/Motivation

In the past, even if not now desired, we've had some useful Drupal body classes added via the theme, like:

  • page-variant--homepage
  • path-frontpage
  • page-node-type-page
  • Others like whether the user is logged in and if the admin tool bar is extended in various ways.

Would it be worth adding those back in? It may just be that when we create a subtheme, these include files are not being copied across or extended.

Steps to reproduce

Run a fresh install of the latest Sector and then create a new subtheme. See if the html and body classes exist.

Proposed resolution

Implement / Extend the Theme and preprocess functions for html and body.
see https://git.drupalcode.org/project/sector_theme/-/blob/1.0.x/includes/ht...

Then update Documentation for themers on how to extend the subtheme.

📌 Task
Status

RTBC

Version

1.0

Component

Documentation

Created by

🇳🇿New Zealand stewest Wellington

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @stewest
  • 🇳🇿New Zealand stewest Wellington

    So the basic premise that we wanted to add body classes with certain information to it, is already covered. By default we get classes:
    "node-2 node-type--sector-page" as per https://git.drupalcode.org/project/sector_theme/-/blob/1.0.x/includes/ht...

    Update: Steps reproduce Sub theme errors.

    When I run:

    php core/scripts/drupal generate-theme --starterkit sector_starterkit NewSubTheme --path themes/custom

    I get:

    Directory themes/custom/NewSubTheme could not be created - so this needs to be done manually

    So I created the custom folder manually and then the php script works. Updating DOCS. (or we could add a .gitkeep file in the folder to make it remain even when empty?)

    Then, I install the theme, from the UI as it didn't want to run from
    `drush en SUBTHEME_NAME -y; drush config-set system.theme default SUBTHEME_NAME -y`

    Then I got this WSOD:

    Drupal\sdc\Exception\InvalidComponentException: [id] Does not match the regex pattern ^[a-z]([a-zA-Z0-9_-]*[a-zA-Z0-9])*:[a-z]([a-zA-Z0-9_-]*[a-zA-Z0-9])*$ in Drupal\sdc\Component\ComponentValidator->validateDefinition() (line 119 of core/modules/sdc/src/Component/ComponentValidator.php).

    I then removed this theme and recreated a new theme, using a lower case name, and then I get no errors. So sub theme documentation perhaps should refer to: SUBTHEME_NAME in lower case?

  • Assigned to gareth.poole
  • Status changed to RTBC about 1 year ago
  • 🇳🇿New Zealand stewest Wellington

    The latest updates, fixing the sub theme generation solves the issues mentioned above.

Production build 0.71.5 2024