CCWidgetSetup

From Open-Xchange
Revision as of 13:15, 22 September 2011 by Dennis Sieben (talk | contribs) (→‎Solution)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Task

You want to provide different preconfigured widgets for certain contexts

Solution

Let's say, we want to configure two widget sets, according to certain brands. We'll call them "Groupware4You", "CollaborationPro" and "OneStopShop".

There is a config cascade enabled property (com.openexchange.frontend.uwa.widgetFile) that governs which widget definition file is used.

Firstly we'll tag the contexts. This will assign the contexts to a certain brand.

Groupware4You Contexts

 changecontext -c1 ... --taxonomy/types=gw4u
 changecontext -c2 ... --taxonomy/types=gw4u

CollaborationPro Contexts

 changecontext -c3 ... --taxonomy/types=cpro
 changecontext -c4 ... --taxonomy/types=cpro

OneStopShop Contexts

 changecontext -c5 ... --taxonomy/types=oss
 changecontext -c6 ... --taxonomy/types=oss

Next, we create the default widget settings in the file /opt/open-xchange/etc/groupware/uwa.properties

com.openexchange.frontend.uwa.widgetFile=g4you_widgets

And the corresponging widget definition file /opt/open-xchange/etc/groupware/widgets/g4you_widgets.yml:

   ads:
     autorefresh: true
     parameter: "{customerType: 'free'}"
     standalone: true
     url: http://www.groupware4you.com/widgets/Ads
     visible: true
     title:Offerings from Groupware 4 You
   newAndNoteworthy:
     autorefresh: false
     parameter: "{customerType: 'free', includeUpsell: 'true'}"
     standalone: true
     url: http://www.groupware4you.com/platformNews
     visible: true
     title: New and Noteworthy


Next, let's define the two other brands. If a context belongs to a certain brand, other widget files will be used.

Create a file /opt/open-xchange/etc/groupware/contextSets/widgetSets.yml.

   cpro:
       withTags: cpro
       com.openexchange.frontend.uwa.widgetFile: cpro_widgets
       
   oss:
       withTags: oss
       com.openexchange.frontend.uwa.widgetFile: oss_widgets


And the corresponding widget files, referred to by the configuration above.

/opt/open-xchange/etc/groupware/widgets/cpro_widgets.yml:

   newAndNoteworthy:
       autorefresh: false
       parameter: "{customerType: 'free', includeUpsell: 'true'}"
       standalone: true
       url: http://www.collaborationpro.com/platformNews
       visible: true
       title: Collaboration Pro, New And Noteworthy

/opt/open-xchange/etc/groupware/widgets/oss_widgets.yml:

   newAndNoteworthy:
       autorefresh: false
       parameter: "{customerType: 'free', includeUpsell: 'true'}"
       standalone: true
       url: http://www.onestopshop.com/platformNews
       visible: true
       title: The One Stop Shop News

This will make the widget files vary along the config cascade.