Class HTMLText represents a variable-length string of up to 2 megabytes, designed to store HTML source. It’s a subclass of DBField; for more information about these database field classes works, see the DBField page.

Instantiation
static $db = array(
  "Content" => "HTMLText",
);

The HTMLText constructor has no special arguments.

Usage in templates

The following $ variables can be used in the template. Replace “Description” with the name of your database field.

  • $Description - Returns an HTML-escaped version of the text.
  • $Description.ATT - Returns a copy of this text suitable for insertion into an HTML attribute (HTML code will be escaped).
  • $Description.RAW - Returns the plain text, with all HTML stripped out.
  • $Description.FirstParagraph - Returns the first paragraph of the HTML from this field.
  • $Description.FirstSentence - Returns the first sentence of the HTML from this field.
  • $Description.LimitWordCount(50) - Returns the first 50 words of the HTML from this field.
  • $Description.Summary(50) - Returns the maximum number of complete sentences that are less than 50 words, up to the first paragraph.
  • $Description.BigSummary(50) - Returns the maximum number of complete sentences that are less than 50 words (can return more than 1 paragraph).
  • $Description.NoHTML - Returns an HTML Text Field without the HTML. Useful for inserting into flash as well as a HTML page
MySQL data type

The Varchar class creates a MySQL field of type mediumtext character set utf8 collate utf8_general_ci.

 
htmltext.txt · Last modified: 2009/03/23 08:36

Please use comments for notes, tips and corrections about the described functionality.
Use the Silverstripe Forum to ask questions.

blog comments powered by Disqus
 
Creative Commons LicenseSilverStripe Documentation by SilverStripe is licensed under a Creative Commons Attribution 3.0 New Zealand License.
Based on a work at doc.silverstripe.com
Recent changes RSS feed Driven by DokuWiki