1

This is related to this question. Outside of item-view.xsl, is there a way to retrieve the handle of the owning collection of an item say for example from the front page? In the front page, there's a list of recently submitted items, but looking at the mets file of a particular item, there is no reference to what collection it belongs.

My use case for this is for example in the recently submitted list, I want to exclude items that belongs to a certain collection. I'm not talking about a restricted collection here. Recently submitted items from that collection should not show up in the front page.

I'm using DSpace version 5.3 Mirage 2 theme.

Thanks in advance.

Community
  • 1
  • 1
euler
  • 1,401
  • 2
  • 18
  • 39
  • 1
    You may be able to set up a filter in `discovery.xml` that takes the items you don't want out of the recently submitted, but I'm not sure, sorry – schweerelos Sep 09 '15 at 21:13
  • @schweerelos, I looked at `discovery.xml` and I have no idea how to setup a filter there. The properties I found there are just for `metadataSortField`, `type`, `max` and `useAsHomePage`. – euler Sep 10 '15 at 03:54
  • I think I was thinking of default filter queries: https://wiki.duraspace.org/display/DSDOC5x/Discovery#Discovery-Addingdefaultfilterqueries%28OPTIONAL%29 but it looks like they're global for all of discovery, not just for recently added. Not sure if you can have a filter just for recently added (from a quick look at the code, probably not). – schweerelos Sep 10 '15 at 04:17
  • @schweerelos, I have successfully retrieved the owning collection name. I tried to add this in the `` block (to exclude it from showing) from this [answer](http://stackoverflow.com/a/32276151/1919069). The problem is if my `recentSubmissionConfiguration` in `discovery.xml` `max` value is 5, and all the first 5 recent submissions were from that collection, my resent submissions will be empty. If I increased the max value eg 100, the recent submissions list excludes items from that collection. Any advice? – euler Sep 10 '15 at 23:48
  • Really I think you've hit the limits of what you can do in the XSL. I think you'll have to do this server-side (ie in Java code) in the class that queries for recent submissions. Set an additional custom filter query here: https://github.com/DSpace/DSpace/blob/master/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/recentSubmissions/RecentSubmissionUtils.java#L42 – schweerelos Sep 11 '15 at 04:06
  • 1
    If you're stuck with only being able to change the XSL, you could try bypassing the class I just linked to and use helix84's mad tricks of querying Solr directly from within the XSL (https://wiki.duraspace.org/display/DSPACE/Solr#Solr-QueryingSolrfromXMLUI). Then build your own recently added list (check the solr log for what query is normally used to construct the recently added list). – schweerelos Sep 11 '15 at 04:07

1 Answers1

2

If you have a handle a/b, you can retrieve the XML for that object.

document("/handle/a/b?XML")

That XML will contain a hierarchy of collections/communities containing the item.

document("handle/a/b?XML")//dri:trail[@target]

The handle for the collection will be in the last trail element containing a target attribute.

terrywb
  • 3,740
  • 3
  • 25
  • 50