|Holds technical, pre-formatted texts (similar to type Text)|
|Provided by:||Semantic MediaWiki|
|Added in version:||1.4.2|
|Removed in version:||still in use|
|Datatype ID:|| |
|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 3.0.0 introduces configuration parameter
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.
Help:Type Code en 1.4.2
- Semantic MediaWiki: User mailing list thread " Unable to query over the last words of a long text value "
- Semantic MediaWiki: GitHub pull request gh:smw:1481
- Semantic MediaWiki: GitHub pull request gh:smw:2536
- Stack Overflow: Question 3489041: Mysql::Error: Specified key was too long; max key length is 1000 bytes