Share Advanced Search

cancel
Showing results for 
Search instead for 
Did you mean: 

Share Advanced Search

resplin
Intermediate
0 5 26K

Obsolete Pages{{Obsolete}}

The official documentation is at: http://docs.alfresco.com



Alfresco Share3.4


Overview


The Alfresco Share 3.4.a release includes a new Advanced Search page with a fully customisable user interface.

Based on customer and partner requests the Advanced Search interface is based on Forms. This allows a search page to be built and customised for any content, folder or custom type in the system. It also allows custom Form controls to be used within the interface.
frame|c|none|Advanced Search - Default Content Search Form
The Forms are defined using the same style of configuration as data input and data output forms found in many places in Alfresco Share, including Document and Folder Details pages and the new Workflow interface.

The following describes example configurations and what is required to achieve common customizations.


Configuration


Adding a new Form to the Advanced Search interface is a two stage process. Firstly you need to override the configuration that defines the list of available forms and the labels used to represent them in the interface. This is the default configuration from share-config.xml:



   <config replace='true' evaluator='string-compare' condition='AdvancedSearch'>
      <advanced-search>
         <forms>
            <form labelId='search.form.label.cm_content' descriptionId='search.form.desc.cm_content'>cm:content</form>
            <form labelId='search.form.label.cm_folder' descriptionId='search.form.desc.cm_folder'>cm:folder</form>
         </forms>
      </advanced-search>
   </config>

Override this section to add a new form. Add an element <form> with appropriate label and description attributes for the type this Form is describing. If the label and description attributes are not set, the name of the type in the Data Dictionary will be used. Each form in the system has an identifier and the identifier of 'search' will be assumed if not set in the configuration above.

You will need to define a search form for each type you wish to be displayed in the user interface. The Search Forms section below details how to construct search Form definitions.

When the Advanced Search user interface is displayed, it reads this configuration and adds each form to the Look for menu.
frame|c|none|Advanced Search - Look For menu
The resolved label attribute is displayed as the visible name of the form in the menu, and the description is used as the tooltip for the menu item.

The fields defined in that Form are then displayed if the user selects it from the menu. The order of the elements in the configuration above defines the order of the forms in the menu and the first form element in the list will be shown by default when the user enters the Advanced Search page.


Search Forms


To add a search Form for a type, or to override the default Forms already provided for cm:content and cm:folder, a Form definition should be configured. For detailed information on Forms and Form definitions see the Forms guide page.

Search forms are added to the Form config for a type and given the identifier of 'search' (a different identifier can be used if set in the configuration detailed above). See share-form-config.xml for default search forms for cm:content and cm:folder types. A Form definition can be added or overridden (eg. cm:folder type:



   <config evaluator='model-type' condition='cm:folder'>
      <forms>
         <form id='doclib-common'>
            <field-visibility>
               <show id='cm:name' />
               <show id='cm:title' force='true' />
               <show id='cm:description' force='true' />
            </field-visibility>
            <create-form template='../documentlibrary/forms/doclib-common.ftl' />
            <appearance>
               <field id='cm:title'>
                  <control template='/org/alfresco/components/form/controls/textfield.ftl' />
               </field>
            </appearance>
         </form>
         <form id='search'>
            <field-visibility>
               <show id='cm:name' />
               <show id='cm:title' force='true' />
               <show id='cm:description' force='true' />
            </field-visibility>
         </form>
      </forms>
   </config>

Note the element <form id='search'>. This is the definition of the 'search' Form for the cm:folder type. The <field-visibility> section defines which properties of the type to display controls for and the <appearance> element specifies additional information to the Forms engine such as which template to use to render the control.


Search Form Example


To add a new custom SOP type as described in the Data Dictionary Guide. First override the advanced-search configuration in share-config-custom.xml and add the following form element:


<form label='SOP Document' description='Standard Operating Procedure Document'>my:sop</form>

Then add the following configuration to define the search Form for that type:



   <config evaluator='model-type' condition='my:sop'>
      <forms>
         <form id='search'>
            <field-visibility>
               <show id='cm:name' />
               <show id='my:publishedDate' />
               <show id='my:authorisedBy' />
            </field-visibility>
            <appearance>
               <field id='my:publishedDate'>
                  <control template='/org/alfresco/components/form/controls/daterange.ftl' />
               </field>
            </appearance>
         </form>
      </forms>
   </config>

The following form is now available for selection in the Advanced Search page:
frame|c|none|Advanced Search - SOP Document Form example


Search Form Controls


Reading the Forms Guide mentioned above will help understand how to add the appropriate Form control for common Data Dictionary types, but here are some examples of controls and configuration suggestions for Advanced Search usage.

There are some caveats to defining forms for use in Advanced Search. Forms are generally designed to be used for data input or read-only data output. For example, during data input some common fields for types are made read-only by the system as they are not appropriate for the user to modify - such as 'Modified Date'. However they do make sense to search against, therefore some changes might be needed from the obvious configuration for a property to allow fields to appear correctly and make sense for a search form.


A property that has a list-of-values constraint defined against it.


Normally the Forms engine would render this using a drop-down that forces the user to always select a value - for a search it may be more appropriate to make the field optional in the form:



   <field id='my:lovproperty'>
      <control template='/org/alfresco/components/form/controls/selectmany.ftl' />
   </field>

A property that is defined as a number datatype.


Normally the Forms engine would render this as a text field enforcing that a number value was entered - for a search it may be more appropriate to display a number range control:



   <field id='my:numberproperty'>
      <control template='/org/alfresco/components/form/controls/numberrange.ftl' />
   </field>

A property that is defined as a date datatype.


Normally the Forms engine would render this as a single date entry calendar control - for a search it may be more appropriate to display a date range control:



   <field id='my:dateproperty'>
      <control template='/org/alfresco/components/form/controls/daterange.ftl' />
   </field>

A property that is read-only when the edit controls for a form are displayed.


Normally the Forms engine would render this as a read-only field, but that can be overridden with the 'forceEditable' attribute:



   <field id='cm:modifier'>
      <control>
         <control-param name='forceEditable'>true</control-param>
      </control>
   </field>

A pseudo property such as 'mimetype' that is displayed using a specific control.


Normally the Forms engine would render this as the default text-field component as it is unsure which template to use, but that can be overridden to display a more appropriate control:



   <field id='mimetype'>
      <control template='/org/alfresco/components/form/controls/mimetype.ftl' />
   </field>

A property that would normally be hidden in Edit mode.


Normally the Forms engine would hide this field because it is part of the cm:titled aspect not the cm:content type definition - for a search it should be forced visible:



   <show id='cm:title' force='true' />

Categories Property


Adding the category selector field:



   <field-visibility>
      <show id='cm:categories' force='true' />
   </field-visibility>
   <appearance>
      <field id='cm:categories'>
         <control>
            <control-param name='compactMode'>true</control-param>
         </control>
      </field>
   </appearance>

Note that in Alfresco 4.0 it is possible to set an additional control-param to enable sub-category searching on the categories control:



   <control-param name='showSubCategoriesOption'>true</control-param>

Tags Property


Adding the taggable selector field:



   <field-visibility>
      <show id='cm:taggable' force='true' />
   </field-visibility>
   <appearance>
     <field id='cm:taggable'>
      <control>
         <control-param name='compactMode'>true</control-param>
         <control-param name='params'>aspect=cm:taggable</control-param>
         <control-param name='createNewItemUri'>/api/tag/workspace/SpacesStore</control-param>
         <control-param name='createNewItemIcon'>tag</control-param>
      </control>
     </field>

  </appearance>
5 Comments