2

我正在尝试使用 plone.app.theming (重氮)动态更改每个页面上的样式,但 Plone 的首页除外。

到目前为止,我已经拼凑了这个,但它打破了我的主题:

<replace css:content="#some-div" if-path="not(body.section-front-page)"
<style type="text/css">
#some-div { margin: 0 2.25em }
</style>
</replace>

任何有关如何编写组合 if-not 路径和动态修改样式的帮助将不胜感激!添加了缺少的结束标签,仍然不起作用。

4

3 回答 3

3

对我来说,您的 rules.xml 文件中似乎有几个错误。

a) 替换需要内容和主题属性。见http://docs.diazo.org/en/latest/basic.html#replace

b)您通常不会将 css 放入您的 rules.xml 文件中。并且它在上面插入的方式不起作用

c) if-path 条件适用于部分 url。并且您正在测试特定类别的身体。你宁愿选择其中之一

if-path="/front-page" 
if-content="body.section-front-page"

(见http://docs.diazo.org/en/latest/advanced.html#conditions-based-on-paths

最好的起点是浏览文档 http://pypi.python.org/pypi/plone.app.theming

下载 plone.org 上的重氮主题之一作为模板 http://plone.org/products?getCategories=themes&getCompatibility=Plone+4.1&SearchableText=diazo

并在http://docs.diazo.org上查找不同的规则

于 2012-03-05T07:57:08.187 回答
1

我不认为 Diazo 是解决此问题的正确工具,请尝试以下 CSS:

#some-div { margin: 0 2.25em }
body.section-front-page #some-div { margin: 0 }

Plone 的部分 css 类的好处是它允许您为整个站点编写一个 CSS 文件,同时仍然针对特定部分的规则。

于 2012-03-05T19:10:22.850 回答
0

假设您的首页是具有“首页”ID 的文档,那么您可以执行以下操作:

<?xml version="1.0" encoding="UTF-8"?>
<rules
    xmlns="http://namespaces.plone.org/diazo"
    xmlns:css="http://namespaces.plone.org/diazo/css">

  <rules css:if-content="body.section-front-page.template-document_view)">
  <!-- here you put rules for the front page only -->
  </rules>

  <rules css:if-content="body:not(.section-front-page.template-document_view)">
    <after css:content-children="head">
      <style>
      #some-div { margin: 0 2.25em; }
      </style>
    </after>
  </rules>

</rules>

例如,指定 .template-document_view 可以帮助您避免在家中使用@@manage-portlets 屏幕。

于 2012-06-08T03:09:54.943 回答