I am using Diazo / XSLT to host the Plone website. On the homepage, Plone gives me the following structure:
<dl>
<dt>
<a href="...">The news item title</a>
</dt>
<dd>
The content of the news item
</dd>
(and so on for the following ones)
</dl>
What I want to convert to something like this:
<div id="news_items">
<div>
<h2><a href="...">The news item title</a></h2>
The content of the news item.
<a class="readmore" href="<the HREF taken from the dt/a tag)">Read more</a>
</div>
(and so on for the following items)
</div>
I am not very familiar with XSLT and Diazo (and used it more to rewrite some existing topics), but I tried several solutions.
The first was to do it twice. First find the "dd" tags, create a structure and after this update, after analyzing all the "dt" tags:
<copy css:theme="#news_items">
<xsl:for-each css:select="#content-core dl dd">
<xsl:element name="div">
<xsl:element name="h2">
</xsl:element>
<xsl:copy-of select="./*" />
<xsl:element name="a">
<xsl:attribute name="class">readmore</xsl:attribute>
Read more
</xsl:element>
</xsl:element>
</xsl:for-each>
</copy>
It creates the structure correctly, but I don’t know how to write the second part. The idea would be this:
<xsl:for-each css:select="#content-core dl dt">
<copy css:theme="#news_item div:nth-child(position()) h2" css:select="a" />
<copy css:theme="#news_item div:nth-child(position()) a.readmore">
<xsl:attribute name="class">
<xsl:value-of select="@class" />
</xsl:attribute>
</copy>
</xsl:for-each>
I know this doesn't make much sense, but I hope you understand this:
I look at every dd tag
, , "h2", , "dd".
( ) "a.readmore" href.
, , ( ). , :
<xsl:for-each css:select="#content-core dl > *">
<xsl:if test="name = dt">
</xsl:if>
<xsl:if test="name = dt">
</xsl:if>
</xsl:foreach>
( , " " ).
, ? ( "h2" "href" " " ).
?
Diazo, , Plone ( , , , , )
.