Reputation: 1411
One of the requirements of the repository I'm working on is to have an Advanced Search
option from the user interface. Since as of DSpace 4, the Discovery faceted/filtered search & browse is enabled by default as mentioned here, I just put a link in the navigation to point that Advanced Search
link to http://myrepository.org/discover
. Now my goal is to suppress the search results whenever the user clicked the Advanced Search
link.
How can I override the search results such that if there's no query string (eg if the user goes directly to /discover
page and no facets were selected), it will only show like in the picture below without the search results and the Now showing items ...
and the pagination divs.
I am using DSpace version 5.3 Mirage 2 Theme
This is what I have tried:
<xsl:template match="dri:list[@id='aspect.discovery.SimpleSearch.list.search-results-repository']">
<xsl:variable name="query-string" select="/dri:document/dri:meta/dri:pageMeta/dri:metadata[@element='request'][@qualifier='queryString']"/>
<xsl:if test="$query-string!=''">
<xsl:apply-templates />
</xsl:if>
</xsl:template>
The code above always suppressed the search results whether I have query strings or not.
EDIT
I have a problem with the template match that I used in my answer. The styling of the sort options was removed.
Can someone help me improve my code such that it will not remove the styling of the sort options? The default sort options should look like this:
I wonder why using that template match removed the styling of the sort options. If I use <xsl:apply-templates/>
, or <xsl:apply-templates select="."/>
instead of <xsl:copy-of select="."/>
, it is not returning the result I want to achieve.
Any advice would be greatly appreciated. Thanks in advance.
Upvotes: 1
Views: 201
Reputation: 1411
After many tries of template match
, I finally achieved what I want to display. This is the template match
that I am using to achieve my goal.
<xsl:template match="dri:div[@id='aspect.discovery.SimpleSearch.div.search-results']">
<xsl:if test="contains(@pageURLMask,'query') or contains(@pageURLMask,'filter')">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:template>
I don't know and not sure if this is fool proof. I've tested this when going directly to /discover
page, no search results displayed and I also tried clicking the search button without entering any values in the search form.
There is a slight problem with this answer. Please see my updated post above.
This is the code that resolved my problems regarding the styling of the sort options.
<xsl:template match="dri:div[@id='aspect.discovery.SimpleSearch.div.search-results']">
<xsl:choose>
<xsl:when test="contains(@pageURLMask,'query') or contains(@pageURLMask,'filter')">
<xsl:apply-templates select="dri:div[@id='aspect.discovery.SimpleSearch.div.masked-page-control']/node()"/>
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="no-search-results"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="no-search-results" match="dri:div[@id='aspect.discovery.SimpleSearch.div.masked-page-control']"/>
Upvotes: 1