1

I've seen in some repositories using XMLUI that instead of the default Communities in DSpace found in the front page, they are displaying featured publications. I wonder how can this be achieved and how are the featured publications list are selected?

One great example of this is WorldBank's Open Knowledge Repository.

euler
  • 1,401
  • 2
  • 18
  • 39

1 Answers1

1

It's probably best to just contact the people running that specific repository - I'm sure there are lots of different ways to implement this sort of thing.

One of "my" DSpace instances has a single featured item ("Read of the week"). It's implemented as a custom XMLUI aspect. The current selection is just stored in a text file in the DSpace directory; we kept it deliberately simple (ie no database involvement) since there was no need to eg keep a history of previously featured items.

The aspect roughly does this:

(1) Add the featured item information to the home page DRI -- using a class that subclasses org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer. In its addBody method, the transformer adds a reference set pointing to the item:

    // reading the featured item's handle from the file on disk,
    // then retrieve the item by handle (instance of org.dspace.content.Item)

    if (item != null) {
        Division readOfWeekHome = body.addDivision("read-of-week-home", "primary repository");
        Division readOfWeek = readOfWeekHome.addDivision("read-of-week", "secondary read-of-week");
        readOfWeek.setHead(READ_OF_THE_WEEK);
        ReferenceSet refset = readOfWeek.addReferenceSet("read-of-week-set", ReferenceSet.TYPE_SUMMARY_LIST, null, "read-of-week");
        refset.addReference(item);
    }

This ends up in the home page DRI like so:

<div id="nz.ac.lconz.irr.dspace.app.xmlui.aspect.readofweek.ReadOfWeekTransformer.div.read-of-week-home" rend="primary repository" n="read-of-week-home">
    <div id="nz.ac.lconz.irr.dspace.app.xmlui.aspect.readofweek.ReadOfWeekTransformer.div.read-of-week" rend="secondary read-of-week" n="read-of-week">
        <head>Read of the Week</head>
        <referenceSet id="nz.ac.lconz.irr.dspace.app.xmlui.aspect.readofweek.ReadOfWeekTransformer.referenceSet.read-of-week-set" rend="read-of-week" n="read-of-week-set" type="summaryList">
            <reference repositoryID="10292" type="DSpace Item" url="/metadata/handle/123456789/1234/mets.xml"/>
        </referenceSet>
    </div>
</div>

I don't recall whether there is any special code in the theme XSL to render this reference set; I believe it just re-uses the rendering of other summaryList reference sets (ie recently added lists) but there is a little bit of custom CSS to increase the font size.

(2) Provide admin screens to let the repo staff pick which item is currently featured (first screen to type in the item's id/handle, second screen to preview the item and confirm the selection) and add an entry to the administrative part of the sidebar so repo staff can access these screens.

The aspect has its own sitemap.xmap to pull in the transformer for the home page and to guide the workflow through the admin screens using the aspect's flowscript. If you don't need the admin screens (eg if you're happy to just edit the file when the featured item changes), your sitemap just needs to pull in the transformer on the home page:

        <!-- Match dspace home page -->
        <map:match pattern="">
            <map:transform type="ReadOfWeekTransformer"/>
            <map:serialize type="xml"/>
        </map:match>

It's on GitHub under 3-Clause BSD:

schweerelos
  • 2,189
  • 2
  • 17
  • 25
  • Hi Andrea, I would really appreciate it if you can show me how your "Read of the week" is implemented. I'm really interested how the selection stored in the text file is pulled and added to the home page DRI. I hope that it would fit here in SO if ever you want to expand your answer. Thanks in advance. – euler Aug 20 '15 at 03:03
  • Hi @euler -- not sure whether you get a notification from SO. I've expanded on my answer and the code is available too, hope it helps. Again I'm not saying this is the only/best way to do it, but it works :) – schweerelos Aug 21 '15 at 04:53
  • Wow! Thanks Andrea. I will definitely implement this. – euler Aug 21 '15 at 08:57
  • Hi Andrea, I would like to ask what is the default/sample entry/values of `featured.item.file` under the `config/modules/lconz-aspect.cfg`? Thanks! – euler Sep 01 '15 at 02:33
  • Hi Andrea, ignore my previous comment/question. It turns out I just need to generate this file first, and then I found out that the content is just the item ID. Thank you so much! I have successfully applied this in our test server. My follow up question is, how can I rearrange the divs in the front page? My "Read of the Week" is added at the bottom of the page, after the recent submissions. I want to display this right after the `news-xmlui.xml` contents and before the community browser. – euler Sep 01 '15 at 04:03
  • 1
    Great to hear you got it working. For the reordering, have a look at this question here: http://stackoverflow.com/questions/25413032/how-to-reorder-dri-divs-in-dspace-xmlui -- Tim's answer has a jquery solution and Terry's one that works in the XSL (I personally would take the XSL route). – schweerelos Sep 01 '15 at 06:23
  • Thanks! Worked perfectly! Can't wait to implement this in our production server if I have the go signal from my boss... – euler Sep 01 '15 at 07:50