Search code examples
dspace

Featured publications in DSpace front page


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.


Solution

  • 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: