Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide the content for the Diazo theming part #1870

Merged
merged 28 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e08c079
Update tips submodules/plone.api submodules/volto
stevepiercy Feb 18, 2025
1f0a07b
Update tip submodules/volto
stevepiercy Feb 18, 2025
cc4288e
Fix broken references (#1868)
stevepiercy Feb 18, 2025
4dd1406
Update tip submodules/plone.api
stevepiercy Feb 18, 2025
710db4f
Update tip submodules/volto
stevepiercy Feb 19, 2025
7e0abed
initial structure of Theming with Diazo
erral Feb 20, 2025
676f204
more doc
erral Feb 20, 2025
4892209
initial structure of Theming with Diazo
erral Feb 20, 2025
df34704
more doc
erral Feb 20, 2025
98a42ea
Merge remote-tracking branch 'origin/erral-diazo-docs' into erral-dia…
stevepiercy Feb 24, 2025
87b4981
- Add diazo to toctree
stevepiercy Feb 24, 2025
a08782e
Clean up grammar, one sentence per line, MyST syntax
stevepiercy Feb 24, 2025
cc749b3
Add language
stevepiercy Feb 24, 2025
0341281
Move concepts and advice into a new Theme development advice section
stevepiercy Feb 24, 2025
bccd9ff
Minor tweaks
stevepiercy Feb 24, 2025
7960810
Rename section to reflect its content
stevepiercy Feb 24, 2025
8cb69c8
Adjust heading level
stevepiercy Feb 24, 2025
273daee
Update diazo.md
erral Feb 24, 2025
99f70f2
Update diazo.md
erral Feb 24, 2025
dee7d89
Update diazo.md
erral Feb 24, 2025
126fa5d
- Make first mention of Diazo a term, already existing in the Glossary
stevepiercy Feb 25, 2025
d0bc7dd
Tweak markup
stevepiercy Feb 25, 2025
f092f6e
Merge branch 'classic-ui-theming-reorg-1645' into erral-diazo-docs
stevepiercy Feb 25, 2025
580bc71
Merge branch 'classic-ui-theming-reorg-1645' into erral-diazo-docs
stevepiercy Feb 25, 2025
5e65e3f
add tinymce templates docs
erral Feb 25, 2025
fd97ddf
Tidy up
stevepiercy Feb 25, 2025
a0779be
Add a label and important admonition about Template plugin removal in…
stevepiercy Feb 25, 2025
2d47570
Remove important admonition about Template plugin
stevepiercy Feb 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions docs/classic-ui/theming/diazo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
---
myst:
html_meta:
"description": "Plone Classic UI theming with Diazo"
"property=og:description": "Plone Classic UI theming with Diazo"
"property=og:title": "Plone Classic UI theming with Diazo"
"keywords": "Plone, Classic UI, theming, Diazo"
---

(classic-ui-theming-diazo-label)=

# Classic UI theming with Diazo

Diazo allows you to apply a theme contained in a static HTML web page to a dynamic website created using any server-side technology.
With Diazo, you can take an HTML wireframe created by a web designer, and turn it into a theme for your favourite CMS, redesign the user interface of a legacy web application without even having access to the original source code, or build a unified user experience across multiple disparate systems, all in a matter of hours, not weeks.

When using Diazo, you will work with syntax and concepts familiar from working with HTML and CSS.
And by allowing you to seamlessly integrate XSLT into your rule files, Diazo makes common cases simple and complex requirements possible.


## Create an add-on package

To create a Diazo theme, you need to create an add-on package with [`plonecli`](https://github.com/plone/plonecli).

```shell
plonecli create addon diazo.theme
```

Answer all the questions.

Next, add a theme called "theme" to the add-on package using `plonecli`.

```shell
cd diazo.theme
plonecli add theme
```

Answer the question of the theme name.


### Theme structure

This process creates a {file}`theme` folder inside {file}`diazo.theme/src/diazo/theme`, with the following structure.

```console
.
├── index.html
├── manifest.cfg
├── package.json
├── README.rst
├── rules.xml
├── styles
│ ├── theme.min.css
│ └── theme.scss
└── tinymce-templates
├── bs-dark-hero.html
├── bs-hero-left.html
└── bs-pricing.html
```


## Integrate an external theme using Diazo

Begin with any theme from outside Plone.
It should be composed of the required HTML, CSS, and JavaScript files.

CSS and JavaScript files should be properly versioned or hashed to avoid any caching problems whenever the theme is updated.

If the CSS file is called {file}`global.css`, and your designer updates the CSS without changing the file name, you will surely face caching issues.
Browsers, varnish, or other proxy servers might cache your files, and not serve them to the end users until the cache expires or gets flushed.

To avoid this issue, CSS bundling techniques that use npm tooling—such as Gulp, Grunt, or Webpack—create hashed or versioned filenames for CSS and JavaScript files.
The following HTML snippets show examples of versioned files.

```html
<link id="frontend-css" rel="stylesheet" href="./css/app.css?v=14" />
<script id="frontend-javascript" src="./js/app.js?v=3"></script>
```

When you have all files of your theme, put them in the {file}`theme` folder, and organize the CSS and JavaScript folders as you received them from your designer.

You may want to remove the `plonecli` generated `styles` and `tinymce-templates` folders.


## Adjust the theme manifest

Open the {file}`manifest.cfg` file.
You will see the following lines.

```cfg
production-css = ++theme++my-shiny-theme/styles/theme.min.css
tinymce-content-css = ++theme++my-shiny-theme/styles/theme.min.css
```

Comment them out as shown.

```cfg
# production-css = ++theme++my-shiny-theme/styles/theme.min.css
# tinymce-content-css = ++theme++my-shiny-theme/styles/theme.min.css
```

This way, you signal that you don't want either Plone or Diazo to manage the CSS files at all.
But it means that you will need to handle them in your design HTML files.


## HTML template structure

Your theme should be as simple as possible.
That will make your {file}`rules.xml` file also as simple as possible.

The {file}`rules.xml` file declares which parts of theme will be replaced by the HTML produced by Plone.

It is a good practice to have a `<div>` element called `content` in your theme, which will contain the maximum space of the content area of your site.
That way you can inject the HTML produced by Plone there using Plone's content section too.

Add a stanza in your {file}`rules.xml` file.

```xml
<replace
css:theme-children="#content"
css:content-children="article#content"
css:if-content="#content"/>
```


## How to theme using Diazo

You can start with the provided {file}`rules.xml` file.
You will need to write your own rules to bring the dynamic content from Plone into the theme.

Sometimes you will face difficult situations where you may find it hard to put items in the same place that Plone produces in very different places.

For instance, you may need to put together the main menu, the language change, and the search box.
Sometimes it is easier to override the corresponding template in Plone, build the new HTML structure there, and replace one thing in the {file}`rules.xml` file than trying to write complex Diazo rules or writing XSLT.

The size of the {file}`rules.xml` file and the number of rules it contains can negatively impact the performance of your site.
5 changes: 3 additions & 2 deletions docs/classic-ui/theming/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Small theme changes—such as the site logo and favicon and minimal CSS changes
Other theming methods should be used for larger customizations or entire website designs.
These other methods include creating an add-on, tweaking the Barceloneta theme, Diazo, and from scratch.

```{todo}
Provide more information about the other methods and why a developer should choose one versus another.
```{note}
For guidance to choose an appropriate theming method for your use case, you can post to the [Plone Community Forum Classic UI category](https://community.plone.org/c/development/classic-ui/56), or join the [Classic UI channel on Discord](https://discord.com/channels/786421998426521600/787254601656827924).
```

## How-to guides
Expand All @@ -29,6 +29,7 @@ Provide more information about the other methods and why a developer should choo
settings-ttw
create-add-on
color-modes
diazo
```

## Reference
Expand Down
Loading