Help:Datatype "Code"

From semantic-mediawiki.org
Jump to: navigation, search
Code
Holds technical, pre-formatted texts (similar to type Text)
Further Information
Provided by: Semantic MediaWiki
Added in version: 1.4.2
Removed in version: still in use
Datatype ID:
_cod
Table of Contents

Code is a built-in datatype of Semantic MediaWiki that is used for technical texts of arbitrary length, such as source code listings. Text is thus very similar to datatype Text, and it has the same restrictions regarding querying and sorting.

The special functionality of Type:Code properties is that they take some effort to preserve the layout and formatting of their values when displaying them on a wiki page. In particular, newlines and indents are preserved in the display, and some special characters such as "<" are escaped to preserve their appearance. Due to the architecture of MediaWiki and Semantic MediaWiki, it is not possible to achieve this behaviour in any other way than by means of a specialised datatype.

Searching within values

Since Semantic MediaWiki 1.8.0 the first 40 characters (if more than 72 characters were stored as property value) or all 72 characters (if a maximum of 72 characters were stored as property value) are searchable as explained on the help page about selecting pages.1 Searching within property values was not possible in earlier versions of Semantic MediaWiki (≤ 1.7.1).

Semantic MediaWiki 2.5.0 introduces full-text search2 which allows to search with in more than just the maximum of 72 characters as described before.

Semantic MediaWiki 3.0.0 introduces configuration parameter $smwgFieldTypeFeaturesSets relational database specific field type features with it's option SMW_FIELDT_CHAR_LONG3 making it possible to extend the searchable length as described here to 300 characters4 without relying on the full-text search feature.


Related query syntax elements

General

Help pageSyntax elementDescription
#ask: annotation query marker
@annotation
Marks an inline query as part of an annotation5
#ask: control query marker
@control=slider
Allows to dynamically alter a result display without the need to reload a page6
#ask: deferred query marker
@deferred
Marks an inline query as deferred from regular parsing6
#ask: hierarchy depth restriction
+depth=
Restricts the hierarchy depth of a query7
#ask: printout column width
+align=
Defines an alignment for the content of a printout column
#ask: printout column width
+width=
Defines a width for a printout column8



This documentation page applies to all SMW versions from 1.4.2 to the most current version.
      Other languages: dezh-hans

Help:Type Code en 1.4.2


References

  1. ^  Semantic MediaWiki: User mailing list thread " Unable to query over the last words of a long text value "
  2. ^  Semantic MediaWiki: GitHub pull request gh:smw:1481
  3. ^  Semantic MediaWiki: GitHub pull request gh:smw:2536
  4. ^  Stack Overflow: Question 3489041: Mysql::Error: Specified key was too long; max key length is 1000 bytes
  5. ^  Semantic MediaWiki: GitHub pull request gh:smw:2572
  6. a b  Semantic MediaWiki: GitHub pull request gh:smw:2398 (Add support for @deferred mode)
  7. ^  Semantic MediaWiki: GitHub issue gh:smw:2662
  8. ^  Semantic MediaWiki: GitHub pull request gh:smw:2677