Farooq Alaulddin
Farooq Alaulddin

Reputation: 125

how to replace nested elements with diazo Rules.xml in Plone5

I am building plone 5 theme and have a question about replacing nested html elements using rules.xml. Please see the structure then read the question at the end.

Plone5 theme file structure

index.html
footer.html
header.html
header_1.html
header_2.html
rules.xml

index.html

This is my default theme page. I have to div that I want them to be replaced with other elements.
I am doing so in the rules.xml.

 ...
 <body>
    <div id="header"/>
    <div>my content. does not need to be replaced. static</div>
    <div id="footer"/>
 </body>
 ...

footer.html

 <div id="footer">
   <div>This is your footer</div>
 </div>

header.html

 <div id="header">
   <div>This is your header</div>
   <div id="header_1"/>
   <div id="header_2"/>
 </div>

header_1.html

 <div id="header_1">
   <div>This is part 1 of your header</div>
 </div>

header_2.html

 <div id="header_2">
   <div>This is part 2 of your header</div>
 </div>

rules.xml

 <rules
    xmlns="http://namespaces.plone.org/diazo"
    xmlns:css="http://namespaces.plone.org/diazo/css"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <!-- in here I am replacing the footer. this works because there is not other elements inside 
    footer.html that needs to be replaced. -->
    <replace
     href="path/to/footer.html"
     css:theme="#footer"
     css:content="#footer"
     method="document"
    /> 

    *** 
     RULE FOR REPLACING
     header
        header_1
        header_2

</rules>

Question

Upvotes: 0

Views: 70

Answers (1)

MrTango
MrTango

Reputation: 610

i don't think that is gonna work. you need to define one template with theme="index.html" and the diazo compiler will build xslt rules in there. then you can use the rules to get content from Plone and even use the href attribute to get content from different urls. with inline rules you could inject parts into your theme or better you could drop parts which are not wanted. So i would put you header / footer variants into the main theme template and use conditional drop rules to clean it out. you also can use different theme templates depending on current path or other selectors from the content side. in Plone you have useful css classes in the body tag for that.

Upvotes: 0

Related Questions