Skip to content

Commit 6f5208a

Browse files
committed
document how to add body classes in classic UI
1 parent 33f7155 commit 6f5208a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

bodyclasses.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Add custom classes to the `body` element
2+
3+
Body classes are generated in the ``LayoutPolicy.bodyClass` method in mdoule `plone.app.layout.globals.layout`.
4+
Contained is a feature to plugin in own body-classes using named adapters.
5+
6+
Create a class like so:
7+
8+
```Python:
9+
from plone.app.layout.globals.interfaces import IBodyClassAdapter
10+
11+
@implementer(IBodyClassAdapter)
12+
class CustomBodyClasses(object):
13+
"""Additional body classes adapter."""
14+
def __init__(self, context, request):
15+
self.context = context
16+
self.request = request
17+
18+
def get_classes(self, template, view):
19+
return ["additional-class", "another-css-class"]
20+
21+
```
22+
23+
Then register the adapter in ZCML:
24+
25+
```XML
26+
<adapteer
27+
factory=".custombodyclasses.CustomBodyClasses"
28+
for="* *"
29+
name="myproject-customclasses"
30+
/>
31+
```

0 commit comments

Comments
 (0)