Dictionary Plugin

  • highlight: =zdrav highlight niet 'zdrav'
  • highlight: set modus: word match or sub match
  • NICE TO HAVE: search (parse) format: table.column=value or table.column overrides
  • refactor _DICTIONARY_COMMAND and _DICTIONARY_SEARCH as they are both essentially much the same

Generic dictionary plugin and application that uses sqlite as backend and Foswiki as frontend.

This dictionary application does not make any assumptions on a database setup. Retrieving and updating can be done using SQL queries (using the sqlite subset).


Query syntax

Uses * wildcards in search string to set scope.

  • =hello - exact match, only matches 'hello' (case sensitive)
  • "hi" - word match, matches 'hi' in the sentence 'O hi Michael!' but not in 'high and low'
  • my* - starts with 'my', matches 'myologist'
  • *dear - ends on 'dear', matches 'oh dear'
  • friend - substring match, matches 'my friend' and 'friends'
  • ~"Frien%" - advanced pattern match to use SQL's LIKE syntax


Parameter Description Required Default value Examples
database Name of database; refers to the settings in configure. If you use more than one database "default" database="german"
search or '' (default) Search query, typically passed using a web form. See Query syntax. required - search="hello"
sqlQuery The SQL search query to handle the search request. You are free to use any SQL syntax (using the sqlite subset).
To pass the search parameter, use the syntax ${search}. Dependent on the search syntax, this parameter is automatically substituted with LIKE='mysearchstring' or ='%mysearchstring%' (and so on).
required - sqlQuery="SELECT * FROM words
  text ${search}
ORDER BY sort_order"
groupByColumn Groups results by a column and returns the results from multiple rows as array. Use FreeMarker syntax to format array values, or use parameter combinedRowSeparators, for example: ${dt_text?join('; ')}   - groupByColumn="text"
combinedRowSeparators Joins array values with a separator string. Pass a list of column name - separator string values.   - combinedRowSeparators="dt_text='; ', text=' - '"
format Parse column data using a FreeMarker template parser. No table name is defined in the syntax! required - format="<strong>${name}</strong>"
formatTemplate Assign a topic as template to format the data. Will override the format parameter. Escape TML formatting to postpone variable rendering.   - formatTemplate="EntryTemplate"
header Header to the search results. Use FreeMarker syntax to substitute the variables search and resultCount.   - header="Searched: <strong>${search}</strong> (${resultCount} <#if resultCount=1>result<#else>results</#if>)"
footer TO IMPLEMENT   - footer=""
noResultText Feedback text in case of no results.   - noResultText="No results found"
hideIfNoResults Set to on to hide the entire search in case of no results.   - hideIfNoResults="on"

showExactMatchesFirst="column name" (or alias column name)

rowSeparator="," => difference between rowSeparator and combinedRowSeparators

CSS classes

Dictionary Plugin uses these CSS classes:
  • .dictionaryExactMatch - any result that is an exact match of the entered search
  • .dictionaryMatchHighlight - any (partial) string match in the results with the entered search

FreeMarker markup

Retrieving values

$rowId $rowNum $resultCount


Function calls in format

You can use a number of function calls to format strings.

Function name Description Examples
createUrl(url_string) Creates a valid url, for example by replacing spaces by underscores. createUrl('${text}')
highlight(total_string, string_to_highlight) Wraps a HTML SPAN element around the term, with CSS class dictionaryMatchHighlight. ${highlight('${text}','${search}')}
Topic revision: r1 - 06 Oct 2017, UnknownUser
This site is powered by FoswikiCopyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback