You can specify an ExtendedConditions section on a BaseQuery to provide functionality roughly equivalent to GN3 extended searches whereby you can execute a search based on a selection made in one listing to generate a new set of results. Typically this provides "show me all items linked to the selected page" type functionality.
Right clicking on a page, displayed in a listing on the Shell main tab, pops up a context menu:
The popup displayed by the AddIn command ShowResultListDesignerContextMenu defined in the class MainAddIn in the file Shell.vb. This command displays the popup from the configured menuset and determines the name first by looking at the ContextMenuName property on the current directory style and then the base query, using the first one that has a value defined. In our example, the page listing was provided by Fred4Pages which has a ContextMenu attribute defined: <BaseQuery Name="Fred4Pages" ObjectTypeName="page" AllowEmptySearches="false" ContextMenuName="PagePopup"> . . . </BaseQuery> If ContextMenuName is not defined either on the BaseQuery or the current DirectoryStyle, the context menu named ResultListPopup is displayed. In our example, the PagePopup menu will be displayed: <ContextMenu Name="PagePopup"> <l:ShellMenuItem Header="Open" CommandParameter="OpenDesignerInTab"/> <Separator/> <l:ShellMenuItem Header="Show Linked Objects" CommandParameter="ShowObjectsLinkedToPage"/> <l:ShellMenuItem Header="Show Assigned Objects" CommandParameter="ShowObjectsAssignedToPage"/> </ContextMenu> |
The Show Linked Objects uses the ExtendedCondition to generate a listing of items linked to the selected page:
A base query can contain one or more ExtendedConditions elements. Each ExtendedConditions performs a specific search. We'll explain ExtendedConditions on the example of the EditionShell base query in the Ted4_Config.xml file. It contains two distinct ExtendedConditions, defined after the SearchList element. The names of ExtendedConditions are: assigned and linked. They provide context search on the selected editions, or pages, for the assigned or linked articles or imgs. If you expand the assigned extended condition, you'll see it has a Name property. The name has to be unique within the parent BaseQuery. Extended condition contains one SearchNode element, that encloses all other elements: To find out how many searches are defined in the extended condition, expand the SearchNode element: you'll see that it's type is SearchConditionList, that means it can contain definitions of more searches, each with one <List element. And, as you can see that there are three list elements in the code below, it means the extended condition 'assigned' can perform three individual, or combined searches (whether searches are individual or combined, depends on the presence and the value of the Optional property - we'll see it later): To find out about every search, you need to expand List elements. If you expand the first List element, you'll see that its Path property defines which attribute is searched for, in that case, it's linkObject.assigns,ie. the assignment attribute of a linkObject. Here we need to remember that in GN4, assignment by default means 'assigned to an edition'. The description describes it as "Assigned", and the operator (Op) is "In". The List element encloses an Ids element of the VariableSearchNode type, whose Name property you have to remember, to specify it later as the 3rd parameter in the caller script. In this example, the name editionIds reminds us that we have to supply ids of one or more editions. The value 'true' of the Optional property defines that this search is performed as individual and not together with all other List elements defined here. Note: if Optional is not specified, its default is "false". The second List element is similar, but it regards assignment to a page (linkObject.assigns~pageRef), and therefore, the Name property value is pageIds, to remind us to supply ids of one or more pages. The value 'true' of the Optional property defines that this search is performed as individual and not together with all other List elements defined here. Note: if Optional is not specified, its default is "false". The third List element defines a filter for object types, so in the below case, we want that search returns only articles and imgs. As the Optional property is missing, its default is False, and that means that the search defined by this List element is always performed. Now, how these searches get called from a menu? The below script, run on a page listing, displayed in Shell, performs the requested: the first parameter is the name of the base query (in that way you point the base query where the extended conditions are defined), the second parameter is the name of the extended condition within the specified base query ('assigned'), and the third parameter is the name of variable search node within the specified extended condition ('pageIds'): ''' <summary>Shows all the objects assigned to the selected pages.</summary> <ShellCommand(CanExecute:="Ena_HasSelectedPageObjects")> _ Public Sub ShowObjectsAssignedToPage() ShowExtendedConditionsOnSelection("EditionShell", "assigned", "pageIds", My.Resources.IDS_EXTCOND_ASSIGNED) End Sub
The complete code (that defines 'assigned' search for edition and page, and 'linked' search for page) is: <BaseQuery Name="EditionShell" ObjectTypeName="linkObject"> <DirectoryStyleList>...</DirectoryStyleList> <SearchList>...</SearchList> <ExtendedConditions Name="assigned"> <SearchNode xsi:type="SearchConditionList" xmlns="http://www.teradp.com/schemas/GN4/1/SearchConditions.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <!-- The objects must be assigned to the specified edition --> <List xsi:type="SearchCondition" Path="[linkObject.assigns]" Description="Assigned" Op="In"> <Ids xsi:type="VariableSearchNode" Name="editionIds" Type="IdList" Optional="true" /> </List> <!-- The objects must be assigned to the specified page --> <List xsi:type="SearchCondition" Path="[linkObject.assigns~pageRef]" Description="Assigned" Op="In"> <Ids xsi:type="VariableSearchNode" Name="pageIds" Type="IdList" Optional="true" /> </List> <List xsi:type="SearchCondition" Op="In" Path="ObjectType.Id" IsStatic="true"> <IdList> <IdName Name="article" /> <IdName Name="img" /> </IdList> </List> </SearchNode> </ExtendedConditions> <ExtendedConditions Name="linked"> <SearchNode xsi:type="SearchConditionList" xmlns="http://www.teradp.com/schemas/GN4/1/SearchConditions.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <List xsi:type="SearchCondition" Path="[linkObject.pageLayers~pageRef]" Description="Linked" Op="In"> <Ids xsi:type="VariableSearchNode" Name="pageIds" Type="IdList" Optional="true" /> </List> <List xsi:type="SearchCondition" Op="In" Path="ObjectType.Id" IsStatic="true"> <IdList> <IdName Name="article" /> <IdName Name="img" /> </IdList> </List> </SearchNode> </ExtendedConditions> </BaseQuery>
|
By default clicking on the option will show the results in a new listing in the current tab group; holding down the Control key when selecting the menu item will create the listing in a new tab group. Holding down the shift key will Navigate to the new results, replacing the current listing with the new results:
The Navigate buttons highlighted above allow you to move back and forwards through the search history. In this case, you can navigate back to the original page listing.
See also
Configuring script based predefined searches
Configuring archive context searches based on selection