xml - Plone - XSLT/Diazo - Replace Plone portal-personaltools Markup -


i attempting replace markup plone portal-personaltools menu, encountering few issues. first issue not sure if xsl transformation running. placing within tag. rules.xml file follows:

<?xml version="1.0" encoding="utf-8"?> <rules xmlns="http://namespaces.plone.org/diazo" xmlns:css="http://namespaces.plone.org/diazo/css" xmlns:xsl="http://www.w3.org/1999/xsl/transform">  <rules css:if-content="#visual-portal-wrapper">  <theme href="theme.html" />  <!-- head elements --> <replace css:theme="html head title" css:content="html head title" /> <after css:theme-children="html head" css:content="html head base" /> <after css:theme-children="html head" css:content="html head script" />  <!-- logo --> <copy attributes="href" css:theme="#brand" css:content="#portal-logo" />  <!-- tabs --> <replace css:theme-children="#tabs" css:content-children="#portal-globalnav" />  <!-- personal tools --> <replace css:theme="#account-info" css:content="#portal-personaltools" />  <!-- not complete xsl transfomation code. trying follow elses code. -->   <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/>  <xsl:template match="/*"> <ul class="list-inline navbar-btn navbar-right" id="account-info"> <xsl:apply-templates select="dt"/> </ul> </xsl:template>  <xsl:template match="dt"> <li> <xsl:apply-templates select="following-sibling::dd[1]"/> </li> </xsl:template> </xsl:stylesheet>  <!-- search --> <copy attributes="action" css:theme="#searchbox" css:content="#portal-searchbox form" /> <copy attributes="name" css:theme="#searchbox .search-query" css:content="#portal-searchbox form .searchfield" />  <!-- edit bar --> <before css:theme-children="#content" css:content="#edit-bar" />  <!-- main columns --> <replace css:content-children="#content" css:theme-children="#content" /> <replace css:content-children="#portal-column-one" css:theme-children="#left-column" /> <replace css:content-children="#portal-column-two" css:theme-children="#right-column" />  <!-- footer --> <replace css:theme-children="#footer" css:content-children="#portal-footer" /> <after css:theme-children="#footer" css:content="#portal-siteactions" />  </rules>  </rules> 

this correct? xsl transformation not complete, not sure running, code trying transform is:

<dl id="portal-personaltools" class="actionmenu deactivated"> <dt class="actionmenuheader"> <a href="#/useractions" id="user-name">admin</a> </dt> <dd class="actionmenucontent"> <ul><li id="personaltools-dashboard"> <a href="#/dashboard">dashboard</a> </li> <li id="personaltools-preferences"> <a href="#/@@personal-preferences">preferences</a> </li> <li id="personaltools-plone_setup"> <a href="#/@@overview-controlpanel">site setup</a> </li> <li id="personaltools-logout"> <a href="#/logout">log out</a> </li> </ul> </dd> </dl> 

into this:

<ul class="list-inline navbar-btn navbar-right" id="account-info"> <li><a class="btn btn-primary" href="login.html">sign in</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"> <li role="presentation"><a role="menuitem" tabindex="-1" href="dashboard.html">dashboard</a></li> <li role="presentation"><a role="menuitem" tabindex="-1" href="preferences.html">preferences</a></li> <li role="presentation"><a role="menuitem" tabindex="-1" href="site.html">site setup</a></li> <li class="divider" role="presentation"></li> <li role="presentation"><a role="menuitem" tabindex="-1" href="index.html">log off</a></li> </ul> </li> </ul> 

update:

i have secondary question regarding how plone displays sign in button versus user actions menu. how modify rules have signin button appear when user not logged in, , while user logged in show user action menu? modified rules.xml @ bottom of post, after addition notes/information.

screenshot based on dan's modifications

screenshot showing button has user name in separate button, , account button user action menus

after making few slight changes solution provided dan, have user action menu displaying user name dropdown showing user action menu while user logged in. while user logged off, have empty twitter bootstrap button no sign in button.

logged out screenshot

logged out screenshot of empty twitter bootstrap button

logged in screenshot

logged in screenshot dropdown active

i html markup similar when user not logged:

<ul id="account-info" class="list-inline navbar-btn navbar-right">     <li>       <a href="login.html" class="btn btn-primary">sign in</a>     </li> </ul> 

but html markup appears whe user not logged in:

<ul id="account-info" class="list-inline navbar-btn navbar-right">     <li></li>     <li class="btn btn-primary dropdown">         <ul aria-labelledby="drop1" role="menu" class="dropdown-menu"></ul>     </li> </ul> 

finally modified rules.xml

<replace css:content="#portal-personaltools">     <ul class="list-inline navbar-btn navbar-right" id="account-info">         <li>             <!--sign out form-->             <!--<li><a href="#" class="btn btn-primary">sign in</a></li>-->         </li>         <li class="btn btn-primary dropdown">             <xsl:apply-templates select="./dt/a" />             <!--<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:attribute name="role">button</xsl:attribute>         <xsl:attribute name="class">dropdown-toggle</xsl:attribute>         <xsl:attribute name="data-toggle">dropdown</xsl:attribute>         <xsl:copy-of select="@*|node()" />         <b class="caret"></b>     </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> 

thanks in advance!

here's gets of way there. replace this not complete xsl transformation code comment 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 modify content on fly.

update (corresponding op's update):

my rule of thumb limit diazo html rewriting predictable, uniform html. otherwise end overly complex xslt that's difficult maintain , prone breakage (e.g. happens when minor plone upgrade alters personal tools markup?) switch different diazo/plone.app.theming capability @ point: the ability fetch content supporting view specifying href attribute. is, replace of personal tools rules one-liner:

<replace css:theme="#account-info" css:content="#account-info" href="/@@account-menu" /> 

... , write browser view account-menu in python package, have python , zope page templates @ disposal.

(note: it's not appropriate here, if browser view simple use plone.app.themingplugins' shortcut registering view without python package.)

or, keep original rule

<replace css:theme="#account-info" css:content="#portal-personaltools" /> 

... , override plone.personal_bar viewlet (which registered in plone.app.layout package). 1 disadvantage markup overridden in unthemed site (i.e. default 'sunburst' theme see @ http://127.0.0.1/plone).

i use diazo rule href, , write own view based on plone.personal_bar viewlet.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -