Guides and Tutorials

Custom Content View for Documentation Items

At the first step of this tutorial, we created a new document type, called documentationItem.

Now we decide that documentation items should be created in specific containers. This will enable us to add specific user actions, listing view and filters on this specific folder.

Creating a Folderish Document Type

In the Nuxeo Platform everything is a document. It means that folders or workspaces are just documents. They have metadata, a life cycle, etc. What makes them a folder is the facet "folderish". Any document that has this facet set up becomes a folderish document type and can have children.

Creating the document type

  1. In Studio > Content model > Document Types, click on New.
  2. Fill in the creation popup and click on Next.

    • Feature ID: TechnicalDocumentationContainer
    • Extends: Nothing
    • Label: Technical Documentation Folder
    • Click on Next.

Why not extend Folder?

We could extend the Folder document type to inherit its folderish facet. But it would also mean inheriting any other facet and schema the Folder document type has. So we decide not to extend Folder and to manually choose the facets we want.

Making the document type folderish

  1. On the TechnicalDocumentationContainer Definition tab, choose the Collaboratives Spaces Category.
  2. Choose a nice icon.
  3. In Facets, select the Document is folderish facet. It will automatically add an Accepted children type section. No children are selected by default. The Show Create Child Action box is checked.
  4. In this Accepted children type section, select documentationItem.

Defining the folder layouts

For our container, we need very few metadata, a title and a description are enough.

  1. Click on the Creation Layout tab.
  2. Click on the icon of the WARNING rowand confirm deletion.
  3. Repeat step 2 on the View and Edit layout tabs.
  4. Click on Save.

Restricting where documentationItem documents can be created

  1. Go to the documentationItem Definition tab.
  2. In the Container Types, remove Folder and Workspace and add TechnicalDocumentationContainer.
  3. Click on Save. Documentation items can now be created in documentation containers only.

Testing your changes

  1. Redeploy your changes on your Nuxeo Platform.
  2. Create a technical documentation container in a workspace.
  3. In the container, create a new document. You only see a documentation item.

Adapting the Listing in a Folder

The information displayed in the Content tab of a documentation container are very generic. We want to display the documentationItem metadata.

In Nuxeo, listings of documents are called Content Views. We will now see how to create a new content view and replace the default content view by our own.

Creating a new content view

  1. In Studio, go to Listings & Views > Content Views and click on New.
  2. Name it TechnicalDocListing.
  3. Click on Next.

Defining the query

We want the documentation container to display the list of its children. This is a common behavior for a folder. So we will keep the default query filter but add a query parameter to get every documents whose parent is the current document.

  1. Edit the query filter to add a parameter ecm:parentId= ?. You should get the filter below:

    ecm:mixinType != 'HiddenInNavigation' AND ecm:isVersion = 0 AND ecm:currentLifeCycleState != 'deleted' and ecm:parentId= ?
    
  2. In the Query parameter, click on Add and type the parameter below. It will define what to use as the value for ecm:parentId= ? defined above.

    #{currentDocument.id}
    

Defining the filter search layout

We also want to be able to filter the documents inside our folder.

  1. In the Search layout part of the form, check Display the form as a filter.
  2. Choose if it should be displayed in a pop-up or a folding form, it is up to you.
  3. In the Search layout, drag and drop the "full text" built-in widget on the search layout so that we can filter by using the full text search.
  4. Drag the Nature metadata from the dublincore schema and drop it to the layout.
  5. Edit the Nature widget
    1. Select a Vocabulary widget type and choose the vocabulary qualNat.
    2. Keep the "=" operator.
  6. Click on Save.

Defining the Results layout

  1. Click on the Results tab.
  2. Drag the following built-in widgets into the results columns:

    • Icon and document type
    • Title with link

      Title with link widget

      You always need that widget if you want to be able to navigate to the documents displayed in the search results.

  3. Add the Nature metadata:
    1. Drag and drop it from the schema dublincore.
    2. Edit the widget to select the Vocabulary widget type and the qualNat vocabulary.
  4. Add the Process metadata:
    1. Drag and drop it from the schema Quality.
    2. Edit the widget to select the Chained vocabulary widget type and the procQual vocabulary.
  5. Add the Modified from the schema dublincore.
  6. Add two columns by clicking the Add column button.
  7. Drag the following built-in widgets:
    • Lifecycle state
    • Version
  8. Click on the icon to edit the columns labels. For instance you don't want a label for the Icon and document type column.
  9. Click on Save. We now have a new content view available but we need to use it with the TechnicalDocumentationContainer.

Using the new content view on the TechnicalDocumentationContainer document type

  1. In the Studio menu, click Content model > Document Types > TechnicalDocumentationContainer.
  2. Click on the Tabs tab.
  3. Click on the Content Views sub-tab
  4. In the Main content field select the content view TechnicalDocListing.
  5. Click on Save.

Testing your changes

  1. Deploy your changes on your Nuxeo Platform.
  2. Go on the documentation folder created sooner and enjoy the result: If you deploy the filter, you will see that you can filter documents by Nature.

Congratulations

You now have a place to create documentation items. This new container leverages the specific metadata of documentation items.

To sum up what we saw:

  • A container document type is a document type with the folderish facet.
  • The Container Types and Accepted Children types define containment rules.
  • The listing of a folder is called a content view and is composed of three elements:

    • a query that can hold dynamic parameters,
    • a filter that can be used in the user interface,
    • a result tab to display the returned documents.

It is now time to add custom behaviors, such as the locking policy we decided initially.

We'd love to hear your thoughts!

All fields required