Here's something that gets you most of the way there. Replace from your This is not a complete XSL transformation code
comment to the last </xsl:stylesheet>
.
<replace css:content="#portal-personaltools">
<ul class="list-inline navbar-btn navbar-right" id="account-info">
<li>
<xsl:apply-templates select="./dt/a" />
</li>
<li class="btn btn-primary dropdown">
<a id="drop1" href="#" role="button" class="dropdown-toggle" data-toggle="dropdown">Account<b class="caret"></b></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="drop1">
<xsl:apply-templates select="./dd/ul/li" />
</ul>
</li>
</ul>
</replace>
<replace css:content="#portal-personaltools dt a">
<a>
<xsl:attribute name="class">btn btn-primary</xsl:attribute>
<xsl:copy-of select="@*|node()" />
</a>
</replace>
<replace css:content="#portal-personaltools dd li">
<li role="presentation">
<xsl:apply-templates select="./a" />
</li>
</replace>
<replace css:content="#portal-personaltools dd li a">
<a role="menuitem" tabindex="-1">
<xsl:attribute name="href">
<xsl:value-of select="@href" />
</xsl:attribute>
<xsl:value-of select="node()" />
</a>
</replace>
This exercises Diazo's ability to modify content on the fly.
Update (corresponding to OP's update):
My rule of thumb is to limit Diazo HTML rewriting only to very predictable, uniform HTML. Otherwise you end up with overly complex XSLT that's difficult to maintain and is prone to breakage (e.g. what happens when a minor Plone upgrade alters the personal tools markup?) I would switch to a different Diazo/plone.app.theming capability at this point: the ability to fetch content from a supporting view by specifying an href
attribute. That is, replace all of your personal tools rules with a one-liner:
<replace css:theme="#account-info" css:content="#account-info" href="/@@account-menu" />
... and write a browser view account-menu
in a Python package, where you have Python and Zope Page Templates at your disposal.
(Note: it's not appropriate here, but if your browser view was very simple you could use plone.app.themingplugins' shortcut for registering a view without a Python package.)
Or, you could keep your original rule
<replace css:theme="#account-info" css:content="#portal-personaltools" />
... and override the plone.personal_bar
viewlet (which is registered in the plone.app.layout
package). One disadvantage is that the markup would also be overridden in the unthemed site (i.e. the default 'Sunburst' theme you see at http://127.0.0.1/Plone
).
I would use the Diazo rule with href
, and write my own view based on the plone.personal_bar
viewlet.