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
- In Studio, in Content model > Document Types, click on New.
Fill in the creation popup and click on Next.
- Feature ID:
TechnicalDocumentationContainer
- Extends: Nothing
- Label:
Technical Documentation Folder
- Feature ID:
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
- On the
TechnicalDocumentationContainer
Definition tab, choose the Collaboratives Spaces Category. - Choose a nice icon.
- 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.
- In this Accepted children type section, select
documentationItem
.
Read more:
Defining the Folder Layouts
The container should just have a title and a description.
- Click on the Creation Layout tab.
- Click on the icon of the WARNING row and confirm deletion.
- Repeat step 2 on the View Layout and Edit Layout tabs.
- Click on Save.
Restricting Where documentationItem Documents Can Be Created
- Go to the
documentationItem
Definition tab. - In the Container Types, remove Folder and Workspaces and add TechnicalDocumentationContainer.
- Click on Save. Documentation items can now be created in documentation containers only.
Testing Your Changes
- Redeploy your changes on your Nuxeo Platform.
- Create a technical documentation container in a workspace.
- 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
- In Studio, go to Listings & Views > Content Views and click on New.
- Name it
TechnicalDocListing
. - 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.
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= ?
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.
- In the Search layout part of the form, leave Display the form as a filter checked and choose Unfolded filter.
- In the Search layout, drag and drop the "Full Text" built-in widget.
- Drag and drop the Nature metadata from the
quality
schema. - Edit the Nature widget.
- Select the widget type "Single directory suggestion" and choose the vocabulary
qualNat
. - Keep the
=
operator.
- Select the widget type "Single directory suggestion" and choose the vocabulary
- Click on Save.
Defining the Results Layout
- Click on the Results tab.
- Add two columns by clicking the Add column button.
Drag the following into the results columns:
- Built-in Widgets > Icon and document type
Built-in Widgets > Title with link
Title with link widgetYou 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 thequalNat
vocabulary. - Widgets by Property >
quality
schema > Process: On the Layout Widget Editor popup, select the Single directory suggestion widget type and theprocQual
vocabulary. - Widgets by Property >
dublincore
schema > Modified - Built-in Widgets > Lifecycle state
- Built-in Widgets > Version
- Click on the icon to edit the columns labels. For instance you don't want a label for the Icon and document type column.
- 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
- In the Studio menu, click Content model > Document Types > TechnicalDocumentationContainer.
- Click on the Tabs tab.
- Click on the Content Views sub-tab.
- In the Main content field select the content view
TechnicalDocListing
. - Click on Save.
Testing Your Changes
- Deploy your changes on your Nuxeo Platform.
- 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.
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.