If you know how to handle Python code and create a browser view, you could define a browser view that gives back some css. I used the following code in a client project to insert some css that sets the nearest header.jpg
as background, so you can have different backgrounds in different sections.
In configure.zcml:
<browser:page
for="*"
permission="zope.Public"
name="header-image-css"
class=".utils.HeaderImageCSS"
/>
In an utils.py file:
HEADER_IMAGE_CSS = """
#portal-header {
background: url("%s") no-repeat scroll right top #FFFFFF;
position: relative;
z-index: 2;
}
"""
class HeaderImageCSS(BrowserView):
"""CSS for header image.
We want the nearest header.jpg in the acquisition context. For
caching it is best to look up the image and return its
absolute_url, instead of simply loading header.jpg in the current
context. It will work, but then the same image will be loaded by
the browser for lots of different pages.
This is meant to be used in the rules.xml of the Diazo theme, like this:
<after css:theme="title" css:content="style" href="@@header-image-css" />
Because we set the Content-Type header to text/css, diazo will put
a 'style' tag around it. Nice.
"""
def __call__(self):
image = self.context.restrictedTraverse('header.jpg', None)
if image is None:
url = ''
else:
url = image.absolute_url()
self.request.RESPONSE.setHeader('Content-Type', 'text/css')
return HEADER_IMAGE_CSS % url
For your use case you could get the roles like this and then return different css based on that information (code untested):
def __call__(self):
from zope.component import getMultiAdapter
pps = getMultiAdapter((self.context, self.request), name='plone_portal_state')
member = pps.member()
roles = member.getRolesInContext(self.context)
css = "#content {background-color: %s}"
if 'Manager' in roles:
color = 'red'
elif 'Reviewer' in roles:
color = 'blue'
else:
color = 'yellow'
self.request.RESPONSE.setHeader('Content-Type', 'text/css')
return css % color