Added by Dennis Dam, last edited by Dennis Dam on Dec 22, 2006  (view change)

Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.
Hippo CMS Version:
v6.04.00
 Experience level:
Developer
 Developer goals:
 

Introduction

There might be situations in which you want different editor groups to use a different set of types. An example might be a multi-site setup, in which you have one folder per site in the root folder of the repository. Each site uses types, which are specific to that site, and should not be used in one of the other sites.
From version 6.04.00, it is possible to filter the contents of the types dropdown in the folder actions view in the documents perspective. There are two steps to achieve this:

  1. Configure the locationmap
  2. Modify types.xml

Configure the locationmap

You need to provide a locationmap to the CMS, which will serve multiple purposes. One of those is mapping CMS folders to type categories. Another purpose is mapping documents to preview urls, which is discussed on this page. A folder should be assigned a unique category. You have to set two build properties to plug the locationmap into the CMS:

CMS build propery description default
cms.locationmap.src The location of the locationmap, e.g. cocoon://extensions/locationmap.xml context://locationmap.xml
cms.locationmap.eventCacheable Set this to true if you generate the locationmap using sources from the repository false

Next, create the locationmap at the correct location, and provide a mapping of folders to categories in the locationmap. An example locationmap:

<locationmap xmlns="http://apache.org/cocoon/locationmap/1.0">

  <components>
    <matchers default="locationmap">
      <matcher
        name="locationmap"
        src="nl.hippo.forrest.locationmap.WildcardLocationMapHintMatcher"/>
    </matchers>
  </components>
  <locator> 

    <match pattern="types:**">
        
      <!-- inside the types:** matcher, it is not necessary to match for the substring "types:" -->
      <match pattern="*:/content/folderA">
        <location src="folderA-category"/>
      </match>

      <match pattern="*:/content/folderB">
        <location src="folderB-category"/>
      </match>

      <!-- "catch all" matcher -->
      <match pattern="**">
        <location src=""/>
      </match>

    </match>

  </locator>

</locationmap>

As you can see, the locationmap needs matches of the form types:<foldername>. The location element's src attribute will return the category associated with the matched folder.

Modify types.xml

Next, you need to associate types in the types.xml with the categories you assigned to folders in the locationmap. This is done by adding a category attribute on each resource you want to categorize:

<types>
  <resources default="text">
    <resource name="A" label="A page">
      ...
    </resource>
    <resource name="B" label="B page" category="folderA-category">
      ...
    </resource>
    <resource name="C" label="C page" category="folderA-category,folderB-category">
      ...
    </resource>
  </resources>
</types>

Type B will only be available in the folder associated with category folderA-category. Type C will only be available only in the folders associated with the categories folderA-category and folderB-category (use a CSV string to assign more than one category to a type).
But.. what happens to type A, since it doesn't have a category assigned? It will not be shown under the folders of categories folderA-category and folderB-category. Where it can be used, depends on the setup of your locationmap. That's why a "catch-all" matcher is useful, at the end of the locationmap (see example above). All left-over folders can be mapped to the "empty" category. In this way, all types without categories can be used in the folders which are not matched specifically in the locationmap.