0

ホームページに特定のカテゴリの記事を表示しようとしています。

xml を削除しました。

注:取得する必要があるカテゴリは id=38 です。これは表示されていますが、現在の記事に含まれているため、偶然かもしれません。

ここで見つけた解決策を使用して、この問題を修正しました。それは十分に単純でした。私のデータソースは、カテゴリを {$ds-categories} としてフィルタリングしていました。それをちょうど 38 に変更したところ、完全に機能しました。それは簡単なことだとわかっていました。

これを行うホームページがあり、表示されるはずの場所に空白の div が出力されます。

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="../utilities/master.xsl"/>
<xsl:import href="../utilities/get-article.xsl"/>
<xsl:import href="../utilities/pagination.xsl"/>
<xsl:import href="../utilities/get-notes.xsl"/>
<xsl:import href="../utilities/get-comments.xsl"/>
<xsl:template match="data">
<div id="content" class="container">
        <div id="content">
          <div class="col content">
            <div class="col span1">
              <h4 class="n4">Recent entries</h4>
            </div>
          </div>
    <xsl:apply-templates select="homepage-articles/entry" mode="short"/>
    <xsl:apply-templates select="homepage-updates/entry" mode="updates"/>
                  </div>
        <div id="sidebar" class="col last">
            <xsl:call-template name="contact"/>
              <xsl:call-template name="social"/>
            <xsl:call-template name="category"/>
            <xsl:call-template name="tag"/>
            <xsl:call-template name="external-links"/>
        </div>
            </div>
</xsl:template>
</xsl:stylesheet>

次に、get-article テンプレートは次のようになります。

  <xsl:template match="entry" mode="updates">
<div>
  <xsl:for-each select="entry[@handle = updates]">
            <div class="post-meta">
              <span><xsl:call-template name="format-date">
                    <xsl:with-param name="date" select="date"/>
                    <xsl:with-param name="format" select="'D M'"/>
                </xsl:call-template></span>
              <span id="year"><xsl:call-template name="format-date">
                <xsl:with-param name="date" select="date"/>
                    <xsl:with-param name="format" select="'Y'"/>
              </xsl:call-template></span>
                <ul>
                    <li>
                        <xsl:text>Tagged as: </xsl:text>
                        <xsl:for-each select="tags/item">
                            <a href="{$root}/archive/tag/{@handle}"><xsl:value-of select="."/></a>
                            <xsl:if test="position() != last()">, </xsl:if>
                        </xsl:for-each>
                    </li>
                    <li><a href="{$root}/post/{title/@handle}#comments"><xsl:value-of select="@comments"/> comment<xsl:if test="@comments != 1">s</xsl:if></a></li>
                </ul>
            </div>
            <div class="post-content last span-7">
                <h3><a href="{$root}/post/{title/@handle}"><xsl:value-of select="title"/></a></h3>
                <xsl:apply-templates select="body/*[position() &lt; 3]" mode="html"/>
                        <xsl:call-template name="get-images" />
              <p style="float: right; clear: both;"><a href="{$root}/post/{title/@handle}" title="Read {title}">Read the full article</a></p>
            </div>
    </xsl:for-each>
        </div>
    </xsl:template>

助けてくれてありがとう!これを解決したら、それ以上の問題にぶつかるのを避けるのに間違いなく役立ちます。

4

1 に答える 1