Tutorials

Custom Content View for Documentation Items

Updated: March 18, 2024

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

Documentation items should be available 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. Folders or workspaces are documents that are set up with the facet "folderish". This facet enables any document type to have children.

Creating the Document Type

  1. In Studio, in 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

Note:

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 automatically adds 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.

Read more:

Defining the Folder Layouts

The container should just have a title and a description.

  1. Click on the Creation Layout tab.
  2. Click on the icon of the WARNING row and confirm deletion.
  3. Repeat step 2 on the View Layout 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 Workspaces 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 Technical Documentation Item.

Adapting the Listing in a Folder

The Content tab of a documentation container shows very generic information. It should show documentationItem metadata instead.

In Nuxeo, listings of documents are called Content Views. To show specific information in a documentation container, you need to create a new content view.

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. So we will keep the default query filter but add a query parameter to get every document 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, leave Display the form as a filter checked and choose Unfolded filter.
  2. In the Search layout, drag and drop the "Full Text" built-in widget.
  3. Drag and drop the Nature metadata from the quality schema.
  4. Edit the Nature widget.
    1. Select the widget type "Single directory suggestion" and choose the vocabulary qualNat.
    2. Keep the = operator.
  5. Click on Save.

Defining the Results Layout

  1. Click on the Results tab.
  2. Add two columns by clicking the Add column button.
  3. Drag the following into the results columns:

    • Built-in Widgets > Icon and document type
    • Built-in Widgets > 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.

    • Widgets by Property > quality schema > Nature: On the Layout Widget Editor popup, select the Single directory suggestion widget type and the qualNat vocabulary.
    • Widgets by Property > quality schema > Process: On the Layout Widget Editor popup, select the Single directory suggestion widget type and the procQual vocabulary.
    • Widgets by Property > dublincore schema > Modified
    • Built-in Widgets > Lifecycle state
    • Built-in Widgets > Version
  4. Click on the icon to edit the columns labels. For instance you don't want a label for the Icon and document type column.
  5. 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

  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 to the documentation folder created earlier and enjoy the results: 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 on which we initially decided.