Loading...
 
Skip to main content
(Cached)

Making or Updating a Theme for Tiki 27

 Current information
The Tiki 27 file organization has stabilized after considerable development, but for any clarification and the latest information, please visit Tiki's Matrix chatroom.

Tiki continues to evolve along with modern web technology methods. For Tiki 27 the file system has been reorganized to be more logical and efficient. More information is here: https://dev.tiki.org/The-Tiki-27-plus-Build-System, with more background information here: https://gitlab.com/tikiwiki/tiki/-/blob/master/_PATH_DOCUMENTATION.md. Also, to compile a theme now (from SCSS to CSS), the script has changed from PHPSCSS to Dart, so the process is faster and it is also the same script that Bootstrap uses.

New location for custom themes

One aspect of this is to put all of the custom, site-specific files in one directory to facilitate backing up the site, moving the site, and so on. In Tiki 27, the included themes are still in the /themes directory, but it's recommended to put custom theme files in this location if the theme is being developed within the Tiki instance (the files are going to be SCSS-compiled): <Tiki root>/_custom/shared/themes/ . If the custom theme is already compiled and ready to use and won't be further SCSS-compiled in this Tiki installation, then see "New location for custom theme CSS files" below.

New location for custom theme top file ("mytheme.scss")

The "top" files of the theme, mytheme.scss, for example, and newsletter.scss, are now in the mytheme/css directory, moved from the mytheme/scss directory. Otherwise, each custom theme still has the same sub-directories as the package themes, the same as before.

New custom theme files hierarchy

In Tiki 26 and earlier

pp
tiki root
|_ themes
|_ mynewtheme
|_ css
|_ mynewtheme.css
|_ newsletter.css (normally generated during SCSS compiling)
|_ fonts
|_ icons
|_ images
|_ mynewtheme_background_image.png (if any)
|_ mynewtheme.png (screenshot thumbnail that displays on Look & Feel admin page)
|_ options
|_ mynewthemeoption
|_ css
|_ mynewthemeoption.css
|_ scss (plus other standard directories if needed)
|_ scss
|_ css-variables.scss (SCSS files beginning with "" won't be compiled into their own CSS files)
|_ mynewtheme.scss
|_ tiki-variables.scss
|
variables.scss
|
variables-dark.scss
|
newsletter.scss
|_ templates
|_ sometemplatefile.tpl (if needed)

/pp

In Tiki 27 and later

pp
tiki root
|_ custom
|
shared
|themes
|
mynewtheme
|_ css
|_ mynewtheme.scss
|_ newsletter.scss
|_ fonts
|_ icons
|_ images
|_ mynewtheme_background_image.png (if any)
|_ mynewtheme.png (screenshot thumbnail that displays on Look & Feel admin page)
|_ options
|_ mynewthemeoption
|_ css
|_ mynewthemeoption.scss
|_ ( . . . plus other standard theme sub-directories if needed)
|_ scss
|_ css-variables.scss (SCSS files beginning with "" won't be compiled into their own CSS files)
|_ tiki-pagetop_colors.scss
|
tiki-selectors.scss
|
variables.scss
|
variables-dark.scss
|
templates
|_ sometemplatefile.tpl (if needed)

/pp

New location for custom theme CSS files

While the component files of the theme are in _custom/shared/themes/ , when these are compiled, the output CSS files of the theme are generated in

<tiki root>/public/generated/_custom/shared/themes/mytheme/ .

This location works the same as <tiki root>/themes so the custom theme will show up in the Look & Feel admin theme selector just like the included themes.

New file paths in top file

All the file paths in the theme's top file ("mytheme.scss") need to be updated as shown in the Tiki 27 example, below right:

In Tiki 26 and earlier

for a theme in the /themes directory
pp
@import "../../base_files/scss/_tiki-bootstrap_functions";

@import "variables"; // Needs to come first, to override Bootstrap defaults.
@import "variables-dark";
@import "../../base_files/scss/_tiki-variables.scss"; // Values/definitions for Tiki variables (outside of Bootstrap variables) such as _tiki-selectors.scss.
@import "../../default/scss/variables"; // Bootstrap default variables, with a few Tiki overrides
@import "../../default/scss/variables-dark"; // Bootstrap dark mode default variables
@import "../../base_files/scss/_tiki-bootstrap_layout_and_components";
@import "css-variables"; // Needs to be loaded after default variables to override them

@import "../../base_files/scss/_tiki-selectors.scss";
@import "../../base_files/scss/_tiki-pagetop_colors.scss"; // Import if needed to specify top and topbar zone colors in more detail
@import "_tiki-selectors.scss";
@import "../../base_files/scss/_external-scripts.scss";
@import "../../base_files/scss/_select2-tiki_colors.scss";
/pp

In Tiki 27 and later (updated)

for a theme in the /_custom/shared/themes directory
pp
@import "base_files/scss/_tiki-bootstrap_functions"; // 1. Functions are included first (so colors, etc. can be manipulated).

@import "base_files/scss/_tiki-variables.scss"; // 2. Default value declarations for Tiki variables and the default vendor Bootstrap variables.
@import "../scss/variables"; // 3. The theme's variable declarations are used when they are imported after the Bootstrap defaults (order changed for Tiki 27).
@import "default/scss/variables-dark"; //4. Values of dark variables if color modes are enabled (Order of importing this and the default variables-dark doesn't seem to make a difference).
@import "../scss/variables-dark"; // 5. Adds default dark variables for any not declared by the theme dark variables file.

@import "base_files/scss/_tiki-bootstrap_layout_and_components"; // 6. Remainder of required Bootstrap parts.
@import "base_files/scss/_tiki-selectors.scss"; // 7. Tiki CSS selectors used globally.
@import "base_files/scss/_tiki-pagetop_colors.scss"; // 8. Optionally imported to group (separately) the top and topbar zone components for styling.
@import "../scss/_tiki-selectors.scss"; // 9. Tiki CSS selectors, including those of external scripts, to be styled by the theme's variables.

@import "../scss/css-variables"; // 10. Imported after default CSS variables to override them.
/pp

As the lists above show, there are fewer files directly imported by the theme in Tiki 27 because one file import was redundant and a few other imports are now combined "upstream" in themes/base_files/scss to reduce duplication across themes and simplify each theme's top file.

New theme compiling method

The theme-building workflow changed between Tiki 26 and 27. Formerly the PHP script to compile themes was part of the Tiki package, but as of Tiki 27 node.js and npm are used so these need to be installed separately from Tiki. The required npm version is between 9.0.0 and 11, and the required node.js version is between 18.0.0 and 22.

Then running npm run watch in the terminal will watch for changes in SCSS files and compile them to CSS, and will report any errors.

 Compiling on Windows
As of this update (July, 2024), there's a glitch when compiling custom themes in Windows. Non-SCSS files and directories are output on a different path than SCSS files, so the theme's images, fonts, templates, etc. directories need to be copied manually to the correct location in public/generated/_custom/shared/themes to be available for the theme.


Page last modified on Wednesday 11 of December, 2024 06:03:52 GMT-0000