私は、Plone WebサイトのテーマとしてDiazo/XSLTを使用しています。ホームページで、Ploneは私に次のような構造を与える:XSLT/Diazo:要素のペアごとに要素を作成する
私はそのような何かに変身したい<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>
:
<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>
私はXSLTとジアゾと本当に身近な(そしてより慣れていませんいくつかの既存のテーマを書き直す)しかし、私はいくつかの解決策を試した。
最初は2回でこれを行うことでした。まず「DT」のタグを解析することによって、それぞれの「DD」タグを探し構造を作成し、その更新後:
<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>
それは正しく構造を作成しますが、私は2番目の部分を記述するのか分かりません。私はそれはあまり意味がありません知っているが、私はあなたがそれのアイデアを得る願ってい
<xsl:for-each css:select="#content-core dl dt">
<!-- Copy the link in the 'dd' tag into the h2 tag, based on the position -->
<copy css:theme="#news_item div:nth-child(position()) h2" css:select="a" />
<!-- Copy the a tag's href in the 'Read more' tag -->
<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>
:
私はそれぞれの「DD」タグの中に見えるアイデアはそのようなものになるだろう
前の手順で作成した 'h2'タグをループ内の位置に基づいて検索し、「dd」タグ内のリンクをコピーします。
"a.readmore"タグを見つけて(位置に基づいて)、hrefをコピーします。
私が考えていた2番目の解決方法は、少し汚れています(どちらも機能しません)。アイデアは、ワンステップでコンテンツを作成することです:
<xsl:for-each css:select="#content-core dl > *">
<xsl:if test="name = dt">
<!-- That the dt tag, we start the 'div' tag and add the h2 tag -->
</xsl:if>
<xsl:if test="name = dt">
<!-- That the dt tag, we copy the content and close the 'div' tag -->
</xsl:if>
</xsl:foreach>
しかし、私は本当に解決策を好きではない(と私は「続きを読む」リンクを作成する方法を参照しません)。
あなたは最初の解決策が実行できると思いますか? (特に、 "h2"タグを設定し、 "Read more"リンクに "href"属性を追加するための2番目のステップ)。 よりよい解決策がありますか?
私だけジアゾを使用することを好むだろうが、それはなんとかではない場合、私は直接、Ploneの中のビューオーバーライドすることができますため
おかげで(少なくとも私が行う方法を知って、私が思うに簡単になること)あなたの助けて。