popoyorc
popoyorc

Reputation: 3

explain alfresco config evaluator="xx" condition="yy"

I am trying alfresco 4.2c.

I am struggling with learning alfresco customization. can someone explain what this xml tag does:

<config evaluator="string-compare" condition="yy">
 ...
 ...
</config>

Is the condition part checking a config file that has a setting yy? which config file is that and where can it be found?

There are also others which I also need to understand. Sorry if this is too basic, but I cant move on to read and understand other alfresco documentations without first understanding this.

I most likely missed the docs that explain these, can someone more knowledgeable direct me to some relevant docs explaining these, please. (I have been jumping from one doc to another without really understanding these.)

Upvotes: 0

Views: 1267

Answers (1)

abarisone
abarisone

Reputation: 3783

Configuration evaluators are used in Alfresco to override and customize the user interface simply modifying xml files.

As reported here

In this file, an evaluator element is used to target the elements for customization. These evaluators are managed by the SpringSurfXmlConfigService. This service is extended by the Alfresco web client framework to include the following default evaluators:

Almost all configuration files ending with the suffix "-config.xml" contain configuation sections like the one you mentioned.

The configuration service uses an amalgamation approach. An object is given as the context and a lookup is performed to retrieve all the configuration that matches that object.

There are several built-in evaluators that can be used i.e. 'string-compare' and 'object-type'. Other custom evaluators can be plugged in by specifying them at the top of the config file (see example below). All configured evaluators are called and passed the context object. If the evaluator matches that section of config is added to the result.

All sections that match are merged into one result, this allows a fine grained configuration approach, and also allows overriding of configuration data. However, this does mean that configuration is sensitive to the order things are defined in the file, basically, the last item wins.

This 'lookup' algorithm, however, can also be customized and plugged in when a config lookup is performed.

This means that as long as the application context is loaded, many objects are registered and you'll be able to add/modify configuration of these objects setting in the condition attribute the object you want to modify.

For example, if you look to your web-client-config-custom.xml file, you will see that there is a Language section containing the languages to be shown on the login page. If you want to add more languages to the list, all you have to do is to add an entry to this list:

<config evaluator="string-compare" condition="Languages">
    <languages>
        <language locale="ca_ES">Catalan</language>
        <language locale="hr_HR">Croatian</language>
        <language locale="cs_CZ">Czech</language>
    </languages>
</config>

Starting from the application-context.xml file you will find that it includes more specific *-context.xml files, leading to the web-client-config.xml file that contains the <element-reader element-name="languages" class="org.alfresco.web.config.LanguagesElementReader" /> to read the languages section.

More examples can be found in the Web Client Customisation Guide

In general you should take a look to official Alfresco documentation and, even if this Config Service wiki post is a bit outdated, it may help you understand the mechanism that didn't change so much even in newer versions.

Upvotes: 4

Related Questions