Recherche
Depuis les versions 5.4 de Nuxeo est apparue la notion de ContentViews.
Un contentView est un ensemble de paramètres qui permet de générer une liste d'objets (typiquement des documents) ainsi que de définir la façon dont ces derniers s'affichent.
On y définit donc :
Les documents de type "conteneurs" (workspaces, folders, sections) sont associées à des contentViews qui gérent la façon dont s'affiche leur contenu.
Si l'on regarde le fichier ecm-types-contrib.xml du composant org.nuxeo.ecm.platform.types, on trouve la définition suivante pour les workspaces :
<type id="Workspace"> <label>Workspace</label> [...] Définition du layout heading (titre), utilisé quel que soit le mode et donc tout le temps présent : <layouts mode="any"> <layout>heading</layout> </layouts> Definition des layouts utilisés lorsque l'on modifie un workspace (formulaire de modification) <layouts mode="edit"> <layout>heading</layout> <layout>dublincore</layout> </layouts> Définition des contentViews utilisés pour l'affichage des contenus du workspace (category=content) <contentViews category="content"> <contentView>document_content</contentView> </contentViews> Définition des contentViews utilisés pour l'affichage du contenus de la corbeille (documents supprimés). <contentViews category="trash_content"> <contentView>document_trash_content</contentView> </contentViews> </type>
si l'on regarde maintenant un extrait du fichier définissant le contentView "document_content", celui-ci se présente ainsi :
<contentView name="document_content"> <title>label.contentview.document_content</title> <translateTitle>true</translateTitle> <showTitle>false</showTitle> DEFINITION DE LA REQUETE PERMETTANT D'OBTENIR LA LISTE DE DOCUMENTS : <coreQueryPageProvider> <property name="coreSession">#{documentManager}</property> <whereClause docType="AdvancedSearch"> <predicate parameter="ecm:fulltext" operator="FULLTEXT"> <field schema="advanced_search" name="fulltext_all" /> </predicate> <predicate parameter="dc:title" operator="FULLTEXT"> <field schema="advanced_search" name="title" /> </predicate> <predicate parameter="dc:modified" operator="BETWEEN"> <field schema="advanced_search" name="modified_min" /> <field schema="advanced_search" name="modified_max" /> </predicate> DEBUT DE LA REQUETE NXQL, LE ? EST REMPLACE PAR LE PARAMETRE CONTEXTUEL #{currentDocument.id} On récupére donc tous les documents fils qui n'ont pas le facet hiddenInNavigation et qui ne sont pas à l'état supprimé. <fixedPart> ecm:parentId = ? AND ecm:isCheckedInVersion = 0 AND ecm:mixinType != 'HiddenInNavigation' AND ecm:currentLifeCycleState != 'deleted' </fixedPart> </whereClause> <parameter>#{currentDocument.id}</parameter> PARAMETRAGE DE TRI PAR DEFAUT (ici le titre du document) et nombre de documents (pagination) affichés par défaut. <sort column="dc:title" ascending="true" /> <pageSize>20</pageSize> </coreQueryPageProvider> DEFINIT LE LAYOUT DU FORMULAIRE DE RECHERCHE PERMETTANT DE FILTRER LES RESULTATS <searchLayout name="document_content_filter" filterDisplayType="quick" /> <showFilterForm>true</showFilterForm> AFFICHE LE SELECTEUR PERMETTANT DE CHANGER LA PAGINATION <showPageSizeSelector>true</showPageSizeSelector> <useGlobalPageSize>true</useGlobalPageSize> DETERMINE LES EVENEMENTS DEVANT ENGENDRER UN RAFRAICHISSEMENT DE LA REQUETE <refresh> <event>documentChanged</event> <event>documentChildrenChanged</event> </refresh> <cacheKey>#{currentDocument.id}</cacheKey> <cacheSize>10</cacheSize> DEFINITION DES LAYOUTS UTILISES POUR LA PRESENTATION DES RESULTATS <resultLayouts> <layout name="document_listing_ajax" title="document_listing" translateTitle="true" iconPath="/icons/document_listing_icon.png" showCSVExport="false" showPDFExport="false" showSyndicationLinks="true" /> <layout name="document_listing_ajax_compact_2_columns" title="document_listing_compact_2_columns" translateTitle="true" iconPath="/icons/document_listing_compact_2_columns_icon.png" showCSVExport="false" showPDFExport="false" showSyndicationLinks="true" /> <layout name="document_listing_ajax_icon_2_columns" title="document_listing_icon_2_columns" translateTitle="true" iconPath="/icons/document_listing_icon_2_columns_icon.png" showCSVExport="false" showPDFExport="false" showSyndicationLinks="true" /> </resultLayouts> <selectionList>CURRENT_SELECTION</selectionList> <actions category="CURRENT_SELECTION_LIST" /> </contentView>
Notre objectif ici va être de ne plus affiché le champ "etat" du document dans les différents listings.
Pour cela, on va créer un nouveau contentView dans lequel on déclarera de nouveaux layouts que nous pourrons ensuite personnaliser.
En s'appuyant sur le modèle vu précédemment, on crée donc un fichier esup-contentview-config.xml que l'on place dans le répertoire templates/custom/config
<?xml version="1.0"?> <component name="org.esup.ecm.webapp.contentview.contrib"> <require>org.nuxeo.ecm.webapp.contentview.contrib</require> <extension target="org.nuxeo.ecm.platform.ui.web.ContentViewService" point="contentViews"> <contentView name="esup_document_content"> <title>label.contentview.document_content</title> <translateTitle>true</translateTitle> <showTitle>false</showTitle> <coreQueryPageProvider> <property name="coreSession">#{documentManager}</property> <whereClause docType="AdvancedSearch"> <predicate parameter="ecm:fulltext" operator="FULLTEXT"> <field schema="advanced_search" name="fulltext_all" /> </predicate> <predicate parameter="dc:title" operator="FULLTEXT"> <field schema="advanced_search" name="title" /> </predicate> <predicate parameter="dc:modified" operator="BETWEEN"> <field schema="advanced_search" name="modified_min" /> <field schema="advanced_search" name="modified_max" /> </predicate> <fixedPart> ecm:parentId = ? AND ecm:isCheckedInVersion = 0 AND ecm:mixinType != 'HiddenInNavigation' AND ecm:currentLifeCycleState != 'deleted' </fixedPart> </whereClause> <parameter>#{currentDocument.id}</parameter> <sort column="dc:title" ascending="true" /> <pageSize>20</pageSize> </coreQueryPageProvider> <searchLayout name="document_content_filter" filterDisplayType="quick" /> <showFilterForm>true</showFilterForm> <showPageSizeSelector>true</showPageSizeSelector> <useGlobalPageSize>true</useGlobalPageSize> <refresh> <event>documentChanged</event> <event>documentChildrenChanged</event> </refresh> <cacheKey>#{currentDocument.id}</cacheKey> <cacheSize>20</cacheSize> <resultLayouts> <layout name="esup_document_listing_ajax" title="document_listing" translateTitle="true" iconPath="/icons/document_listing_icon.png" showCSVExport="false" showPDFExport="false" showSyndicationLinks="true" /> <layout name="esup_document_listing_ajax_compact_2_columns" title="document_listing_compact_2_columns" translateTitle="true" iconPath="/icons/document_listing_compact_2_columns_icon.png" showCSVExport="false" showPDFExport="false" showSyndicationLinks="true" /> <layout name="esup_document_listing_ajax_icon_2_columns" title="document_listing_icon_2_columns" translateTitle="true" iconPath="/icons/document_listing_icon_2_columns_icon.png" showCSVExport="false" showPDFExport="false" showSyndicationLinks="true" /> </resultLayouts> <selectionList>CURRENT_SELECTION</selectionList> <actions category="CURRENT_SELECTION_LIST" /> </contentView> <contentView name="esup_document_trash_content"> <title>label.contentview.document_trash_content</title> <translateTitle>true</translateTitle> <showTitle>false</showTitle> <coreQueryPageProvider> <property name="coreSession">#{documentManager}</property> <whereClause docType="AdvancedSearch"> <predicate parameter="ecm:fulltext" operator="FULLTEXT"> <field schema="advanced_search" name="fulltext_all" /> </predicate> <predicate parameter="dc:title" operator="FULLTEXT"> <field schema="advanced_search" name="title" /> </predicate> <predicate parameter="dc:modified" operator="BETWEEN"> <field schema="advanced_search" name="modified_min" /> <field schema="advanced_search" name="modified_max" /> </predicate> <fixedPart> ecm:parentId = ? AND ecm:isCheckedInVersion = 0 AND ecm:mixinType != 'HiddenInNavigation' AND ecm:currentLifeCycleState = 'deleted' </fixedPart> </whereClause> <parameter>#{currentDocument.id}</parameter> <sort column="dc:title" ascending="true" /> <pageSize>20</pageSize> </coreQueryPageProvider> <searchLayout name="document_content_filter" filterDisplayType="quick" /> <showFilterForm>false</showFilterForm> <showPageSizeSelector>true</showPageSizeSelector> <useGlobalPageSize>true</useGlobalPageSize> <refresh> <event>documentChanged</event> <event>documentChildrenChanged</event> </refresh> <cacheKey>#{currentDocument.id}</cacheKey> <cacheSize>10</cacheSize> <resultLayouts> <layout name="esup_document_listing_ajax" title="document_listing" translateTitle="true" iconPath="/icons/document_listing_icon.png" showCSVExport="true" showPDFExport="false" showSyndicationLinks="true" /> <layout name="esup_document_listing_ajax_compact_2_columns" title="document_listing_compact_2_columns" translateTitle="false" iconPath="/icons/document_listing_compact_2_columns_icon.png" showCSVExport="true" showPDFExport="false" showSyndicationLinks="true" /> <layout name="esup_document_listing_ajax_icon_2_columns" title="document_listing_icon_2_columns" translateTitle="true" iconPath="/icons/document_listing_icon_2_columns_icon.png" showCSVExport="true" showPDFExport="false" showSyndicationLinks="true" /> </resultLayouts> <selectionList>CURRENT_SELECTION_TRASH</selectionList> <actions category="CURRENT_SELECTION_TRASH_LIST" /> </contentView> <contentView name="esup_section_content"> <title>label.contentview.section_content</title> <translateTitle>true</translateTitle> <showTitle>false</showTitle> <coreQueryPageProvider> <property name="coreSession">#{documentManager}</property> <whereClause docType="AdvancedSearch"> <predicate parameter="ecm:fulltext" operator="FULLTEXT"> <field schema="advanced_search" name="fulltext_all" /> </predicate> <predicate parameter="dc:title" operator="FULLTEXT"> <field schema="advanced_search" name="title" /> </predicate> <predicate parameter="dc:modified" operator="BETWEEN"> <field schema="advanced_search" name="modified_min" /> <field schema="advanced_search" name="modified_max" /> </predicate> <fixedPart> ecm:parentId = ? AND ecm:isCheckedInVersion = 0 AND ecm:mixinType != 'HiddenInNavigation' AND ecm:currentLifeCycleState != 'deleted' </fixedPart> </whereClause> <parameter>#{currentDocument.id}</parameter> <sort column="dc:title" ascending="true" /> <pageSize>20</pageSize> </coreQueryPageProvider> <searchLayout name="document_content_filter" filterDisplayType="quick" /> <showFilterForm>true</showFilterForm> <showPageSizeSelector>true</showPageSizeSelector> <useGlobalPageSize>true</useGlobalPageSize> <refresh> <event>documentChanged</event> <event>documentChildrenChanged</event> </refresh> <cacheKey>#{currentDocument.id}</cacheKey> <cacheSize>10</cacheSize> <resultLayouts> <layout name="esup_document_listing_ajax" title="document_listing" translateTitle="true" iconPath="/icons/document_listing_icon.png" showCSVExport="true" showPDFExport="false" showSyndicationLinks="true" /> <layout name="esup_document_listing_ajax_compact_2_columns" title="document_listing_compact_2_columns" translateTitle="true" iconPath="/icons/document_listing_compact_2_columns_icon.png" showCSVExport="true" showPDFExport="false" showSyndicationLinks="true" /> <layout name="esup_document_listing_ajax_icon_2_columns" title="document_listing_icon_2_columns" translateTitle="true" iconPath="/icons/document_listing_icon_2_columns_icon.png" showCSVExport="true" showPDFExport="false" showSyndicationLinks="true" /> </resultLayouts> <selectionList>CURRENT_SELECTION_SECTIONS</selectionList> <actions category="CURRENT_SELECTION_SECTIONS_LIST" /> </contentView> <contentView name="esup_orderable_document_content"> <title>label.contentview.orderable_document_content</title> <translateTitle>true</translateTitle> <showTitle>false</showTitle> <coreQueryPageProvider> <property name="coreSession">#{documentManager}</property> <whereClause docType="AdvancedSearch"> <predicate parameter="ecm:fulltext" operator="FULLTEXT"> <field schema="advanced_search" name="fulltext_all" /> </predicate> <predicate parameter="dc:title" operator="FULLTEXT"> <field schema="advanced_search" name="title" /> </predicate> <predicate parameter="dc:modified" operator="BETWEEN"> <field schema="advanced_search" name="modified_min" /> <field schema="advanced_search" name="modified_max" /> </predicate> <fixedPart> ecm:parentId = ? AND ecm:isCheckedInVersion = 0 AND ecm:mixinType != 'HiddenInNavigation' AND ecm:currentLifeCycleState != 'deleted' </fixedPart> </whereClause> <parameter>#{currentDocument.id}</parameter> <sort column="ecm:pos" ascending="true" /> <sortable>false</sortable> <pageSize>25</pageSize> </coreQueryPageProvider> <searchLayout name="document_content_filter" filterDisplayType="quick" /> <showFilterForm>true</showFilterForm> <showPageSizeSelector>true</showPageSizeSelector> <useGlobalPageSize>true</useGlobalPageSize> <refresh> <event>documentChanged</event> <event>documentChildrenChanged</event> </refresh> <cacheKey>#{currentDocument.id}</cacheKey> <cacheSize>10</cacheSize> <resultLayouts> <layout name="esup_document_listing_ajax" title="document_listing" translateTitle="true" iconPath="/icons/document_listing_icon.png" showCSVExport="true" showPDFExport="false" showSyndicationLinks="true" /> </resultLayouts> <selectionList>CURRENT_SELECTION</selectionList> <actions category="CURRENT_SELECTION_LIST" /> <actions category="ORDERABLE_CURRENT_SELECTION_LIST" /> </contentView> </extension> </component>
On a défini ici plusieurs layouts spécifiques (commençant par esup-) pour la présentation des résultats, il faudra s'occuper par la suite de la définition de ces derniers. Cette étape est décrite dans le chapitre sur les layouts.
Il faut maintenant spécifier que ce sont ces contentViews qu'il faut utiliser. Pour ce faire, on crée un fichier esup-contentview-config.xml que l'on place dans le répertoire templates/custom/config
<?xml version="1.0" encoding="UTF-8"?> <component name="org.esup.ecm.platform.types"> <require>org.nuxeo.ecm.platform.types</require> <require>org.nuxeo.dam.types</require> <extension target="org.nuxeo.ecm.platform.types.TypeService" point="types"> <type id="Root"> <label>Server Root</label> <icon>/icons/folder.gif</icon> <bigIcon>/icons/folder_100.png</bigIcon> <description>serverRoot.description</description> <category>SuperDocument</category> <default-view>view_domains</default-view> <subtypes> <type hidden="create">Domain</type> </subtypes> <layouts mode="any"> <layout>heading</layout> </layouts> <layouts mode="edit"> <layout>heading</layout> <layout>lightdublincore</layout> </layouts> <contentViews category="content"> <contentView>esup_document_content</contentView> </contentViews> <contentViews category="trash_content"> <contentView showInExportView="false"> esup_document_trash_content </contentView> </contentViews> </type> <type id="Domain"> <label>Domain</label> <icon>/icons/domain.gif</icon> <bigIcon>/icons/domain.gif</bigIcon> <category>SuperDocument</category> <description>Domain.description</description> <default-view>view_documents</default-view> <create-view>create_domain</create-view> <views> <view id="user_dashboard" value="user_dashboard" /> <view id="opensocial_dashboard" value="opensocial_dashboard" /> </views> <subtypes> <type hidden="create">WorkspaceRoot</type> <type hidden="create">SectionRoot</type> <type hidden="create">TemplateRoot</type> </subtypes> <layouts mode="any"> <layout>heading</layout> </layouts> <layouts mode="edit"> <layout>heading</layout> <layout>lightdublincore</layout> </layouts> <contentViews category="content"> <contentView>esup_document_content</contentView> </contentViews> <contentViews category="trash_content"> <contentView showInExportView="false"> esup_document_trash_content </contentView> </contentViews> </type> <type id="WorkspaceRoot"> <label>WorkspaceRoot</label> <icon>/icons/workspace.gif</icon> <bigIcon>/icons/workspace_100.png</bigIcon> <category>SuperDocument</category> <description>WorkspaceRoot.description</description> <icon-expanded>/icons/workspace_open.gif</icon-expanded> <default-view>view_documents</default-view> <subtypes> <type>Workspace</type> </subtypes> <layouts mode="any"> <layout>heading</layout> </layouts> <layouts mode="edit"> <layout>heading</layout> <layout>lightdublincore</layout> </layouts> <contentViews category="content"> <contentView>esup_document_content</contentView> </contentViews> <contentViews category="trash_content"> <contentView showInExportView="false"> esup_document_trash_content </contentView> </contentViews> </type> <type id="TemplateRoot"> <label>TemplateRoot</label> <icon>/icons/folder_template.gif</icon> <bigIcon>/icons/template_100.png</bigIcon> <icon-expanded>/icons/folder_template_open.gif</icon-expanded> <category>SuperDocument</category> <description>TemplateRoot.description</description> <default-view>view_documents</default-view> <subtypes> <type>Workspace</type> </subtypes> <layouts mode="any"> <layout>heading</layout> </layouts> <layouts mode="edit"> <layout>heading</layout> <layout>lightdublincore</layout> </layouts> <contentViews category="content"> <contentView>esup_document_content</contentView> </contentViews> <contentViews category="trash_content"> <contentView showInExportView="false"> esup_document_trash_content </contentView> </contentViews> </type> <type id="Workspace"> <label>Workspace</label> <icon>/icons/workspace.gif</icon> <bigIcon>/icons/workspace_100.png</bigIcon> <icon-expanded>/icons/workspace_open.gif</icon-expanded> <category>Collaborative</category> <description>Workspace.description</description> <default-view>view_documents</default-view> <create-view>create_workspace</create-view> <subtypes> <type>Workspace</type> <type>Folder</type> <type>OrderedFolder</type> <type>File</type> <type>Note</type> </subtypes> <layouts mode="any"> <layout>heading</layout> <!--<layout>file</layout>--> </layouts> <layouts mode="edit"> <layout>heading</layout> <!--<layout>file</layout>--> <layout>lightdublincore</layout> </layouts> <contentViews category="content"> <contentView>esup_document_content</contentView> </contentViews> <contentViews category="trash_content"> <contentView showInExportView="false"> esup_document_trash_content </contentView> </contentViews> </type> <type id="SectionRoot"> <label>SectionRoot</label> <icon>/icons/folder.gif</icon> <bigIcon>/icons/folder_100.png</bigIcon> <icon-expanded>/icons/folder_open.gif</icon-expanded> <category>SuperDocument</category> <description>SectionRoot.description</description> <default-view>view_documents</default-view> <subtypes> <type>Section</type> </subtypes> <layouts mode="any"> <layout>heading</layout> </layouts> <layouts mode="edit"> <layout>heading</layout> <layout>lightdublincore</layout> </layouts> <contentViews category="content"> <contentView>esup_section_content</contentView> </contentViews> <contentViews category="trash_content"> <contentView showInExportView="false"> esup_document_trash_content </contentView> </contentViews> </type> <type id="Section"> <label>Section</label> <icon>/icons/folder.gif</icon> <bigIcon>/icons/folder_100.png</bigIcon> <icon-expanded>/icons/folder_open.gif</icon-expanded> <category>Collaborative</category> <description>Section.description</description> <default-view>view_documents</default-view> <subtypes> <type>Section</type> </subtypes> <layouts mode="any"> <layout>heading</layout> </layouts> <layouts mode="edit"> <layout>heading</layout> <layout>lightdublincore</layout> </layouts> <contentViews category="content"> <contentView>esup_section_content</contentView> </contentViews> <contentViews category="trash_content"> <contentView showInExportView="false"> esup_document_trash_content </contentView> </contentViews> </type> <type id="Folder"> <label>Folder</label> <icon>/icons/folder.gif</icon> <bigIcon>/icons/folder_100.png</bigIcon> <icon-expanded>/icons/folder_open.gif</icon-expanded> <category>Collaborative</category> <description>Folder.description</description> <default-view>view_documents</default-view> <subtypes> <type>Folder</type> <type>OrderedFolder</type> <type>File</type> <type>Note</type> </subtypes> <layouts mode="any"> <layout>heading</layout> </layouts> <layouts mode="edit"> <layout>heading</layout> <layout>lightdublincore</layout> </layouts> <contentViews category="content"> <contentView>esup_document_content</contentView> </contentViews> <contentViews category="trash_content"> <contentView showInExportView="false"> esup_document_trash_content </contentView> </contentViews> </type> <type id="OrderedFolder"> <label>OrderedFolder</label> <icon>/icons/ordered_folder.png</icon> <bigIcon>/icons/ordered_folder_100.png</bigIcon> <icon-expanded>/icons/ordered_folder_open.png</icon-expanded> <category>Collaborative</category> <description>OrderedFolder.description</description> <default-view>view_documents</default-view> <subtypes> <type>Folder</type> <type>OrderedFolder</type> <type>File</type> <type>Note</type> </subtypes> <layouts mode="any"> <layout>heading</layout> </layouts> <layouts mode="edit"> <layout>heading</layout> <layout>lightdublincore</layout> </layouts> <contentViews category="content"> <contentView>esup_orderable_document_content</contentView> </contentViews> <contentViews category="trash_content"> <contentView showInExportView="false"> esup_document_trash_content </contentView> </contentViews> </type> <type id="File"> <label>File</label> <icon>/icons/file.gif</icon> <bigIcon>/icons/file_100.png</bigIcon> <category>SimpleDocument</category> <description>File.description</description> <default-view>view_documents</default-view> <layouts mode="any"> <layout>heading</layout> <layout>file</layout> </layouts> <layouts mode="edit"> <layout>heading</layout> <layout>file</layout> <layout>esupdublincore</layout> </layouts> <!-- all content already on summary page --> <layouts mode="view" /> </type> <type id="Note"> <label>Note</label> <icon>/icons/note.gif</icon> <bigIcon>/icons/note_100.png</bigIcon> <category>SimpleDocument</category> <description>Note.description</description> <default-view>view_documents</default-view> <layouts mode="any"> <layout>heading</layout> <layout>note</layout> </layouts> <layouts mode="summary"> <layout>note_summary_layout</layout> </layouts> <layouts mode="edit"> <layout>heading</layout> <layout>note</layout> <layout>esupdublincore</layout> </layouts> <layouts mode="view"> <layout>note</layout> </layouts> </type> <type id="AdvancedSearch"> <label>Advanced Search</label> <icon>/icons/advanced_search.gif</icon> <bigIcon>/icons/folder_100.png</bigIcon> <default-view>view_documents</default-view> </type> </extension> </component>
Note : Nous avons également introduit deux nouveaux layouts dans de fichier : esupdublincore et lightdublincore que nous utliserons dans lechapitre sur les layouts.