It turned out to be quit a simple change. Add an additional field to the
org.dspace.app.xmlui.configuration.Theme object to hold the metadata field
and value to match,
modify org.dspace.app.xmlui.configuration.XMLUIConfiguration to include the
new Theme object field in its work, and
modify org.dspace.app.xmlui.cocoon.ThemeMatcher to add matching of the
metadata field and its value:

if (rule.hasMetadata()) {
  if (dso == null) {
    continue;
  }
  String[] parts = rule.getMetadata().split("[\\=]");
  if (parts.length != 2) {
     continue;
   }
   Metadatum[] md = dso.getMetadataByMetadataString(parts[0]);
   if (md.length < 1) {
     continue;
   }
   if (!md[0].value.equals(parts[1])) {
     continue;
  }
}
So now to have a particular theme for an item with a specific dc.type all I
do is add the following line(s) to the xmlui.xconf file:
<theme name="New Theme" metadata="dc.type=<some dc.type>" path="<some theme
path>"/>

It seems to work. Thanks guys.

John


On Wed, 15 Apr 2015 at 11:11 John Preston <byhisde...@gmail.com> wrote:

> Ok Guys I'm gonna try the following and comments are welcome.
>
> 1) I'm gonna add code in org.dspace.app.xmlui.configuration.Theme that
> stores an additional tag (similar to handle=) called 'metadata' with
> appropriate methods hasMetadata() etc.
>
> 2) In ThemeMatcher I add an additional section testing if if 
> (rule.hasMetadata()
> && dso.getMetadata(...)....)
> and so on and so forth
>
> John
>
> On Mon, 13 Apr 2015 at 15:38 John Preston <byhisde...@gmail.com> wrote:
>
>> I've done this in the past it's just that it tends to get messy the more
>> you add and I'm looking for a cleaner solution.
>>
>> John
>>
>> On Mon, Apr 13, 2015, 3:34 PM Peter Dietz <pe...@longsight.com> wrote:
>>
>>> Another route to go would be to use a single theme, and then have XSL
>>> logic that changes the behavior of item-view, depending on that metadata
>>> value. In my theme I've been changing the display behavior depending on the
>>> mimetype of the bitstreams (audio, video, document), as well as metadata
>>> values, ex ds.firstpage.side=left [2] alters the bookreader to have a the
>>> first page of a scanned book display on the left side of a bookreader spine.
>>>
>>> [1]
>>> https://github.com/LongsightGroup/DSpace/blob/0f246b859df06cdd539f87896cca1635fffcafd2/dspace-xmlui/src/main/webapp/themes/mirage2/xsl/aspect/artifactbrowser/item-view.xsl#L908
>>> [2]
>>> https://github.com/LongsightGroup/DSpace/blob/longsight-4_x/dspace-xmlui/src/main/webapp/themes/mirage2/xsl/aspect/artifactbrowser/item-view.xsl#L879
>>>
>>> I'm longing to add a Collection Configuration page, where you could add
>>> some configuration values to a collection, and then have the theme change
>>> actions based on that. i.e. collection.map.show = true
>>>
>>> ________________
>>>
>>> Peter Dietz
>>> Longsight
>>> www.longsight.com
>>> pe...@longsight.com
>>> p: 740-599-5005 x809
>>>
>>> On Mon, Apr 13, 2015 at 1:51 PM, Mark Diggory <mdigg...@atmire.com>
>>> wrote:
>>>
>>>> John,
>>>>
>>>> Seems sensible, what would be ideal is if we could arrive at some sort
>>>> of language for the field that would allow for matching on other criteria.
>>>>
>>>> Some days I wonder why this isn't just in the cocoon sitemap,
>>>> xmlui.xconf is very limiting and unwieldy. Alternatively, making the
>>>> matcher into Service and giving it a spring based configuration with
>>>> matching rules would also be extremely extensible without needing special
>>>> "xmlui.xconf parsing code" that you'd need to extend/alter to create your
>>>> own config attributes.
>>>>
>>>> Mark
>>>>
>>>>
>>>>
>>>>
>>>> On Mon, Apr 13, 2015 at 10:27 AM John Preston <byhisde...@gmail.com>
>>>> wrote:
>>>>
>>>>> So if I add some rule patterns to the xmlui.xconf (regex=? section)
>>>>> that dont break the existing ones, and add code to ThemeMatcher (lines 105
>>>>> to 120+) that use the uri to instantiate the dspace object and find some
>>>>> metadata and match to the rule pattern (similar to the checking handles
>>>>> code) then I should be good to go.
>>>>>
>>>>>
>>>>> John
>>>>>
>>>>> On Mon, 13 Apr 2015 at 11:18 Mark Diggory <mdigg...@atmire.com> wrote:
>>>>>
>>>>>> John,
>>>>>>
>>>>>> You could add a theme match on Item handle. We have overridden
>>>>>> ThemeMatcher in other projects and extended it with additional support 
>>>>>> for
>>>>>> features such as requested domain name. I can see it feasible to extend 
>>>>>> it
>>>>>> to support checking for specific metadata fields in the 5.x DSpaceObject
>>>>>> metadata.
>>>>>>
>>>>>>
>>>>>> https://github.com/DSpace/DSpace/blob/master/dspace-xmlui/src/main/java/org/dspace/app/xmlui/cocoon/ThemeMatcher.java
>>>>>>
>>>>>> Cheers,
>>>>>> Mark
>>>>>>
>>>>>>
>>>>>> On Mon, Apr 13, 2015 at 9:12 AM John Preston <byhisde...@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi All, Can anyone say if it is possible within DSpace 5.x codebase
>>>>>>> to install a different xmlui theme based on a dc.type similar to what is
>>>>>>> done to install a theme per collection or community, or if not then how
>>>>>>> easy it would be for me to add a hack or code to implement such a beast.
>>>>>>>
>>>>>>> John
>>>>>>>
>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
>>>>>>> Develop your own process in accordance with the BPMN 2 standard
>>>>>>> Learn Process modeling best practices with Bonita BPM through live
>>>>>>> exercises
>>>>>>> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
>>>>>>> event?utm_
>>>>>>>
>>>>>>> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF_______________________________________________
>>>>>>> Dspace-devel mailing list
>>>>>>> Dspace-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/dspace-devel
>>>>>>>
>>>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
>>>> Develop your own process in accordance with the BPMN 2 standard
>>>> Learn Process modeling best practices with Bonita BPM through live
>>>> exercises
>>>> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
>>>> event?utm_
>>>> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
>>>> _______________________________________________
>>>> Dspace-devel mailing list
>>>> Dspace-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/dspace-devel
>>>>
>>>>
>>>
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Dspace-devel mailing list
Dspace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspace-devel

Reply via email to