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
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 > 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
Ok, for my future reference, the code below is what I used to override the recent submissions list in the homepage using Mirage 2 theme. Thanks to @terrywb for his answer.
<xsl:template match="dri:div[@id='aspect.discovery.SiteRecentSubmissions.div.site-recent-submission']/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:variable name="issue-date" select="document($externalMetadataURL)//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="substring($issue-date,1,4) = date:year()">
<xsl:comment> External Metadata URL: <xsl:value-of select="$issue-date"/> </xsl:comment>
<xsl:comment> Current year is: <xsl:value-of select="date:year()"/> </xsl:comment>
<ul class="ds-artifact-list list-unstyled">
<xsl:apply-templates select="." mode="summaryList"/>
</ul>
</xsl:if>
</xsl:for-each>
</xsl:template>
Note that I used
<xsl:template match="dri:div[@id='aspect.discovery.SiteRecentSubmissions.div.site-recent-submission']/dri:referenceSet[@rend='recent-submissions']">
This is because if I just use <xsl:template match="dri:referenceSet[@rend='recent-submissions']">
, it will also override the list after you clicked the View more
link. I also used the date:year()
XSLT extension to capture the current year so that I don't have to hardcode or change the year every year.
I changed 'Recently Added' modifying these code block in page-strucutre.xsl:
<!-- Otherwise use default handling of body -->
<xsl:otherwise>
<xsl:apply-templates />
</xsl:otherwise>
By this:
<!-- Otherwise use default handling of body -->
<xsl:otherwise>
<xsl:apply-templates select="*[not((@n='site-home'))]"/>
</xsl:otherwise>
This change will block render of 'Recently Added' and 'Community View'.
To show 'Recently Added' in other place on page-strucutre, I have create one template for this:
<xsl:template name="buildCustomRecent">
<ul class="list-group-plain" style="list-style: none;">
<xsl:variable name="countRecent">
<xsl:value-of select="count(/dri:document/dri:body/dri:div/dri:div/dri:referenceSet/*)" />
</xsl:variable>
<xsl:for-each select="/dri:document/dri:body/dri:div/dri:div/dri:referenceSet/*">
<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:variable name="title"
select="document($externalMetadataURL)//dim:field[@element='title'][not(@qualifier)]"/>
<xsl:variable name="author"
select="document($externalMetadataURL)//dim:field[@element='contributor'][@qualifier='author'][1]/text()"/>
<xsl:variable name="issue-date"
select="document($externalMetadataURL)//dim:field[@element='date'][@qualifier='issued'][1]/text()"/>
<xsl:variable name="urlObjId" select="document($externalMetadataURL)//mets:METS/@OBJID"/>
<li>
<a>
<xsl:attribute name="href">
<xsl:value-of select="$urlObjId"/>
</xsl:attribute>
<xsl:value-of select="$title"/>
</a>
<br/>
<xsl:value-of select="concat($author,' (',$issue-date,')')"/>
<br/>
</li>
</xsl:for-each>
<xsl:if test="$countRecent=0">
<xsl:text>No itens to show.</xsl:text>
</xsl:if>
</ul>
</xsl:template>