BBCode is a lighweight markup language designed to let users format their messages. It can be used in many forums on the web. Its tags are similar to HTML tags and are entered in square brackets.
Users can use Bulletin Board code in their forum posts if it is enabled. You have to allow the use of BBCode in the properties of the forum or forum group on their General tab. The following table explains particular BBCode tags and properties that have to be enabled on the General tab in order for the tags to be functional.
Example |
Description |
Property on General tab |
[url]http://example.org[/url] [url=http://example.com]Example[/url] |
Makes the text link leading to the URL. |
Enable URL macros in posts |
[img]http://www.imagesxy.com/img.bmp[/img] [img=200x50]http://www.imagesxy.com/img.bmp[/img] [img=200]http://www.imagesxy.com/img.bmp[/img] |
Displays an image located at the URL. The optional parameter resizes the image. It can be added either in format <width>x<height> or <max side size>. |
Enable image macros in posts |
[quote]quoted text[/quote] [quote=Administrator]quoted text[/quote] |
Displays text in a grey box; used for quotations. The optional parameter displays Administrator wrote: and the quoted text on a new line. |
Enable quote macros in posts |
[code]code example[/code] |
Displays text in monospaced format; used for code snippets. |
Enable code snippet macros in posts |
[b]bold text[/b] [strong]bold text[/strong] |
Makes the text bold. |
Enable bold font macros in posts |
[i]italicized text[/i] [em]italicized text[/em] |
Makes the text italic. |
Enable italics font macros in posts |
[u]underlined text[/u] |
Underlines the text. |
Enable underline font macros in posts |
[s]strikethrough text[/s] |
Strikes the text through. |
Enable strike font macros in posts |
[color=red]Red Text[/color] [color=#f00]Red Text[/color] [color=f00]Red Text[/color] [color=#ff0000]Red Text[/color] [color=ff0000]Red Text[/color] |
Sets the text color. |
Enable font color macros in posts |
URLs in BBcode macros
All URLs in macros (URL, IMG) are validated as a URL to avoid XSS and resolved into their absolute URL equivalents. The following URL formats can be used:
• | www.google.com – URL starting with www. |
• | http://devnet.kentico.com – URL starting with protocol |
• | ~/CMSDesk/default.aspx – Virtual path |
• | ../default.aspx – Relative URLs |
• | /KenticoCMS/default.aspx – Server relative URL |
API for the BBcode macros
There is an easy way how to resolve macros in ASPX or codebehind code. To resolve all the macros (recommended), use method:
string CMS.CMSHelper.CMSContext.ResolveDiscussionMacros(string inputText)
Or you can use the CMS.GlobalHelper.DiscussionMacroHelper class to resolve macros with particular settings using the ResolveMacros method from an object of this class.
Page url: http://devnet.kentico.com/docs/devguide/index.html?bb_code_support.htm