Including theme snippets in diazo

Hi all,

I have the following use case:

My diazo theme will include one of more theme html files depending on the part of the site which is visited. I am able to create a rule which conditionally loads a html template.

I want to include a common html fragment mega-menu.html in any of the templates rather than duplicating the html.

|--[html]--|--index.html
|          |--services.html
|          |--blog.html
|          |--mega-menu.html
|
|--rules.xml

If I replace the nav element from one of the template with my mega-menu nav e.g. like this:

<replace css:theme="nav" css:content="nav" href="++theme++my.theme/html/mega-menu.html" />

the fragment is included but I am unable to apply any further customizations.

How can this be done?

@mtrebron,
It will take some slight refactoring but you can get what you want done with collective.themefragments.

More info here:

Hi David,

Cheers for the link! I looked at that, and the jbot variant, but decided against it because it adds another layer of complexity. Preferably, a designer who can create a bootstrap based theme but does not necessarily know Plone or PageTemplates should be able to maintain/extend the current theme.

While typing, I revisited this stackoverflow question

This seems to do what I want, but only if used in the top-level rules element


<replace css:theme="nav">
    <xsl:call-template name="nav-replacement" />
</replace>        

<xsl:template name="nav-replacement" match="nav">
    <xsl:element name="nav">
        <xsl:apply-templates select="document('++my.theme/html/mega-menu.html',$diazo-base-document)/html/body/div/nav/node() "/>
    </xsl:element>
</xsl:template> 
<drop css:content="nav .navbar-toggle" />


I'll see how far I get if I attempt my replace again in the root rules...

Edit: the original replace rule does not work in the top-level root element.

with this simplified version, dropping the element works but redefining does not...

<replace css:theme="nav">
    <xsl:apply-templates select="document('++my.theme/html/mega-menu.html',$diazo-base-document)/html/body/div/node() "/>
</replace>
<replace css:content="nav .navbar-brand" css:content="#portal-logo"/>
Attribute css:content redefined [11:68]
Rules document could not be parsed!

Plone Foundation Code of Conduct