Extract the attribute of a tag from Plone site and make it the contents of a tag in theme

237 Views Asked by At

I'm trying to extract the attribute of a tag in my Plone site and make it the contents of a tag in my theme.

The specific usecase:

I'd like to extract the plone site title from #portal-logo, the markup in the Plone site looks like this:

<a id="portal-logo" title="Cool Plone Site" accesskey="1" href="http://mysite">
      <img src="http://mysite/logo.png" 
          alt="Cool Plone Site" 
          title="Cool Plone Site" 
          height="56" width="215">
</a>

The title should be inserted between h1 tags in the header tag of my template

<header>
     <h1>Cool Plone Site</h1>
</header>
2

There are 2 best solutions below

2
On BEST ANSWER

This solved my problem:

<replace css:theme-children="header h1">
     <xsl:value-of select="//*[@id='portal-logo']/@title"/>
</replace>

The key here is theme-children. I'd love to be able to use css:select to grab the title attribute, but this works and is still acceptably elegant :)

2
On

Why don't you use the title tag instead? Something along the lines of

<replace content-children="/html/head/title" theme-children="/body/header/h1" />

should yield the desired results, since the logo's title attribute is constructed from portal_state/navigation_root_title anyway.