Start page
Start page

Start page / Plug-In Development / Examples / Module: Editorial Search and Replace / Usage

<< Chapter “Compilation, Installation, and Configuration”

Usage

The example module Editorial Search and Replace provides simple search and replace functionality within the SiteArchitect. It may be used to search pages and sections, dataset, media elements, or templates for a text string and replace occurrences of that text with another text segment.

The search and replace process is subdivided into two steps:

  • Search
    FirstSpirit store elements are searched for a specific text string based upon filter settings specified before a search run. Elements matching the search settings are listed in a report, clicking on a search result in the report allows cycling through the search text's occurrences within that element.
  • Replacement
    If a replacement text has been submitted before the search run, a "Replace All" button will be available for each search result in the report. Clicking that button will cause all identified search text occurrences within the store element to be replaced with the replacement text.

Important This module is an example implementation to demonstrate the code structure and data flow in complex SiteArchitect plug-ins. Although its functionality was designed to support a real-world use case, use of the module in production environments is not supported.

Report structure

The Editorial Search and Replace user interface has a structure similar to the global search in SiteArchitect. It is divided into two areas:

  • The upper area allows search parameter entry, including definition of a search string and an optional replacement string as well as options to specify which project content should be searched for search string occurrences.
  • The lower area displays a list of search results, showing the number of search string occurrences.

Search parameter entry

The fields in the upper report area allow specification of a search string and an optional replacement string as well as options which specify what project content should be searched for search string occurrences.

  • Search for...
    Search for occurrences of this text
  • Replace with...
    Replace occurrences of the search string with this text
  • Case-sensitive
    If enabled, search results will only include occurrences of the search text which match the search text exactly. If disabled, search results will contain occurrences of the search text, disregarding its letter case.
  • Selection of element types which should be considered in the search and replace process:
    • Pages and sections
    • Datasets
    • Media
    • Templates
  • Selection of project languages which should be considered in the search and replace process
  • Editorial Search and Replace
    Pressing this button will start a new search with the search settings specified in the fields above.

Search results

Search result list structure
The results of the search process are displayed as a list in the lower area. Each store element which includes at least one occurrence of the search text is displayed with the following information:

  • Icon indicates the element type (e.g. page, section, etc.)
  • Title the element's name
  • Number of occurrences indicates how many search text occurrences have been identified in the element's data as well as the number of input components and the number of languages which contain search text occurrences

Conditions for search result identification
Search result collection for the search types "Pages and Sections" and "Datasets" is dependent upon the module's project-specific configuration in ServerManager. Search in the element types page, section, and dataset will only consider elements based upon templates which have been activated for search and replace.

Search result collection within DOM Editor (CMS_INPUT_DOM) and DOM Table Editor (CMS_INPUT_DOMTABLE) also depends upon activation of format and link templates for search and replace:

  • DOM content is searched hierarchically.
  • A DOM node will be searched only if its associated template has been activated for search and replace.
  • If a DOM node is not considered in a search run, its child DOM nodes will not be considered either.
  • For links embedded in DOM content, only the link text will be considered for search and replace; the link's other form data will not be considered.

Inspecting a search result
Clicking on an entry in the search result list will cause the associated store element to be displayed in the workspace area. For search text occurrences in an element's data form as well as in templates, the first occurrence will be highlighted. Additionally, the search text and (if specified) the replacement text will be highlighted in all of the element's data forms.

Important Highlighting of search text is done on a per-element basis. This means that occurrences of the search text which will not be replaced may also be highlighted. This may occur in DOM editors in which occurrences of the search text are present within blocks based on a format template which is not activated for search and replace.

Repeatedly clicking on a search result entry will cycle through the search text occurrences within the element's data by input component and project language.

Replacing search text occurrences

If the most recent search run was configured with a replacement text, each entry in the search result list will feature a "Replace all" button which is visible while the mouse pointer hovers over the entry. Clicking this button will replace all found occurrences of the search text with the replacement text.

<< Chapter “Compilation, Installation, and Configuration”

© 2005 - 2015 e-Spirit AG | All rights reserved. | Last change: 2014-10-22