覆盖主页中最近添加的列表 [英] Override recently added list in home page

查看:33
本文介绍了覆盖主页中最近添加的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以覆盖主页中的最近添加列表.默认行为是任何新提交的项目都显示在列表中,而不管其发布日期如何.有没有办法覆盖它,以便仅显示例如在两年内发布的最新提交的出版物(或有条件的 if dc.date.issued => 2014)?

我使用的是 DSpace 5.3 Mirage 2 主题.

更新

使用

有什么建议吗?

解决方案

最近项目的 DSpace 配置文件 (discovery.xml) 将允许您设置用于提取最近项目的元数据字段.您可以在集合之间更改该字段.您可以设置要拉取的最大项目数,但不能设置其他过滤条件.

您需要使用如下逻辑在 XSLT 中设置该条件.

<xsl:for-each select="dri:reference"><xsl:variable name="issue-date" select="document(@url)//dim:field[@element='date'][@qualifier='issued'][1]/text()"/><!--假设日期符合 YYYY-MM-DD 语法,简单的字符串比较应该可以工作.需要一个 XSLT 扩展来计算当前日期.--><xsl:if test="$issue-date &gt; 2014"><ul class="ds-artifact-list"><xsl:apply-templates select="*[not(name()='head')]" mode="summaryList"/></xsl:if><xsl:for-each></xsl:模板>

以下 stackoverflow 答案指示如何将 java 函数合并到 DSpace XSLT 样式表中:参见 如何缩短DSpace中显示的文件名

I wonder if it's possible to override the Recently Added list in the home page. The default behavior is that any new submitted items are displayed in the list regardless of its issue date. Is there a way to override it such that only the latest submitted publications issued for example within two years (or a conditional if dc.date.issued => 2014) are displayed?

I am using DSpace 5.3 Mirage 2 theme.

UPDATE

Using @terry's answer, here is the code I tried:

<xsl:template match="dri:referenceSet[@rend='recent-submissions']">
    <xsl:for-each select="dri:reference">
        <xsl:variable name="externalMetadataURL">
            <xsl:text>cocoon:/</xsl:text>
            <xsl:value-of select="@url"/>
            <!-- No options selected, render the full METS document -->
        </xsl:variable>
        <xsl:comment> External Metadata URL: <xsl:value-of select="$externalMetadataURL"/> </xsl:comment>
        <xsl:variable name="issue-date"  select="document($externalMetadataURL)//dim:field[@element='date'][@qualifier='issued'][1]/text()"/>
        <xsl:comment> External Metadata URL: <xsl:value-of select="$issue-date"/> </xsl:comment>

        <!--
           Assuming dates conform to YYYY-MM-DD syntax, a simple string compare should work.
           An XSLT extension would be needed to computer the current date.
        -->
        <xsl:if test="$issue-date &lt; 2014">
            <xsl:apply-templates select="."/>
        </xsl:if>
    </xsl:for-each>
</xsl:template>

Also, as per suggestion of @schweerelos from my other post, I put a comment before the document() call to see if the metadata from the $externalMetadataURL were retrieved properly.

Viewing the source code in by browser, the metadata were retrieved properly (although it is not respecting my condition).

View Source

<div id="aspect_discovery_SiteRecentSubmissions_div_site-home" class="ds-static-div primary repository">
    <h2 class="ds-div-head page-header">Recently Added</h2>
    <div id="aspect_discovery_SiteRecentSubmissions_div_site-recent-submission" class="ds-static-div secondary recent-submission">
    <!-- External Metadata URL: cocoon://metadata/handle/10862/2260/mets.xml-->
    <!-- External Metadata URL: 2015-->
    <!-- External Metadata URL: cocoon://metadata/handle/10862/2265/mets.xml-->
    <!-- External Metadata URL: 2015-->
    <!-- External Metadata URL: cocoon://metadata/handle/10862/2261/mets.xml-->
    <!-- External Metadata URL: 2015-->
    <!-- External Metadata URL: cocoon://metadata/handle/10862/2262/mets.xml-->
    <!-- External Metadata URL: 2015-->
    <!-- External Metadata URL: cocoon://metadata/handle/10862/2263/mets.xml-->
    <!-- External Metadata URL: 2015-->
<p id="aspect_discovery_SiteRecentSubmissions_p_recent-submission-view-more" class="ds-paragraph recentSubmissionViewMore">
<a href="/recent-submissions">View more</a>

And this is the DRI generated:

<div id="aspect.discovery.SiteRecentSubmissions.div.site-home" rend="primary repository" n="site-home">
    <div id="aspect.discovery.SiteRecentSubmissions.div.site-recent-submission" rend="secondary recent-submission" n="site-recent-submission">
        <head>Recently Added</head>
        <referenceSet id="aspect.discovery.SiteRecentSubmissions.referenceSet.site-last-submitted" rend="recent-submissions" n="site-last-submitted" type="summaryList">   
            <reference repositoryID="10862" type="DSpace Item" url="/metadata/handle/10862/2260/mets.xml"/>
            <reference repositoryID="10862" type="DSpace Item" url="/metadata/handle/10862/2265/mets.xml"/>
            <reference repositoryID="10862" type="DSpace Item" url="/metadata/handle/10862/2261/mets.xml"/>
            <reference repositoryID="10862" type="DSpace Item" url="/metadata/handle/10862/2262/mets.xml"/>
            <reference repositoryID="10862" type="DSpace Item" url="/metadata/handle/10862/2263/mets.xml"/>
        </referenceSet>
        <p id="aspect.discovery.SiteRecentSubmissions.p.recent-submission-view-more" rend="recentSubmissionViewMore" n="recent-submission-view-more">
            <xref target="/recent-submissions">View more</xref>
        </p>
    </div>
</div>

Even if I remove my condition (eg <xsl:if test="$issue-date &lt; 2014">), I'm still having blanks as the View Source code and the image below shows.

Any advice please?

解决方案

The DSpace config file for recent items (discovery.xml) will allow you to set the metadata field that is used to pull recent items. You can alter that field from collection to collection. You can set the maximum number of items to pull, but you cannot set other filter criteria.

You will need to set that criteria in your XSLT using logic like the following.

<xsl:template match="dri:referenceSet[@rend='recent-submission']">
   <xsl:for-each select="dri:reference">
     <xsl:variable name="issue-date"  select="document(@url)//dim:field[@element='date'][@qualifier='issued'][1]/text()"/>

    <!-- 
       Assuming dates conform to YYYY-MM-DD syntax, a simple string compare should work.
       An XSLT extension would be needed to computer the current date.
    -->
    <xsl:if test="$issue-date &gt; 2014">
      <ul class="ds-artifact-list">
        <xsl:apply-templates select="*[not(name()='head')]" mode="summaryList"/>
      </ul>
    </xsl:if>
  <xsl:for-each>
</xsl:template>

The following stackoverflow answer indicates how to incorporate a java function into a DSpace XSLT stylesheet: See How to shorten filename displayed in DSpace

这篇关于覆盖主页中最近添加的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆