I recently worked on a DSpace theme with a custom input form for a student project … and it was a good reason to pull (some small) pieces of code I’ve worked on before but I never documented. In hopes that someday I -or someone else- can find this useful, below are short notes on what I ended-up doing and reusing.
Code for generating value-pairs
When creating a custom input form in DSpace, users can define the kind of interactive widget to put in the form to collect the Dublin Core values. The input-type options include: onebox, twobox, dropdown, etc. Details are available in Chapter 14 on the DSpace documentation page. If you need to create an element with predefined values (e.g. drop down menu), then you’ll need to define a value-pairs section –usually a few lines of XML. If you’re creating an element with 3-5 values, you may just type everything … but if you’re creating an element with more than 100 values (e.g. list of all majors and minors), you may find this page useful … I’ve re-used this code/page a couple of times in the last month
jQuery for collapsing menus in DSpace
I have also updated this small .js file to include 3 basic behaviors: a) don’t collapse the 1st browse ds-simple-list when viewing the front-page; b) collapse the 1st browse ds-simple-list when viewing individual community/collection pages; and c) only collapse the search box OR don’t collapse anything for logged-in users. The actual code is in the collapse.js file, and it’s now live on the Scholarly Commons site as well.
Variable with handle for individual collection/community
When creating customized themes, sometimes we just need to get rid of everything that links back to the default DSpace homepage. A workaround that seems to do the trick is the code below, the “coll” variable contains the handle of the active collection or community and it can be re-used anywhere on the theme.xsl file. An example of this tweak is in action on the horizontal menu on this CPATH Repository page.
<xsl:variable name="coll" select="/dri:document/dri:meta/dri:pageMeta /dri:metadata[@element='focus'][@qualifier='container']" /> <xsl:variable name="coll" select="substring-after($coll,'hdl:')"/> <xsl:variable name="coll" select="concat('/handle/', $coll)"/> <xsl:value-of select="$coll"/>
Related items in Google Scholar
The latest test was a “Related Items” link added in the itemSummaryView-DIM template. The idea is to add an extra metadata element that will allow users to click and go to Google Scholar to view related items. The trick is to get an item’s title, replace all the empty spaces with a + sign and add the new text at the end of the GS URL e.g. http://scholar.google.com/scholar?q=Highlights+survey+nursing+home+industry+trends
… and speaking of re-using things, it seems like the new Open Knowledge Repository of the World Bank will now facilitate the access and re-use of hundreds of publications under their new Open Access Policy -what a great example of an Open Access initiative and a DSpace instance at the international level.