|
||
Bulletin Board code (the BBCode abbreviation is commonly used) is a lightweight markup language designed to let users format text of their messages. It is used in many forums on the web, not just on websites created with Kentico CMS. Its tags are similar to HTML tags and are entered in square brackets.
Users can use BBCode in their forum posts only if it is enabled. You have to allow use of BBCode when editing () a forum or forum group, on the General tab of its editing interface in CMS Desk -> Tools -> Forums.
The following table explains particular BBCode tags. The first column shows icons on the BB editor toolbar. Clicking one of these icons encloses text selected in the text within the respective tags. The second column shows examples of text enclosed within the tags. The Description column explains what effects the tags have on the formatting. The last column lists respective properties on the General tab that have to be enabled in order for the tags to be functional.
Icon |
Example |
Description |
Property on the General tab |
[url]http://example.org[/url] [url=http://example.com]Example[/url] |
Makes the text a link leading to the URL.
One of the following three options can be selected:
No - the macros are not functional and the icon is not displayed Simple dialog - clicking the icon displays a simple dialog where the URL of the link can be entered manually Advanced dialog - clicking the icon displays the Insert link dialog where the URL can be selected in various ways |
Enable links 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>.
One of the following three options can be selected:
No - the macros are not functional and the icon is not displayed Simple dialog - clicking the icon displays a simple dialog where the URL of the link can be entered manually Advanced dialog - clicking the icon displays the Insert image dialog where the image can be selected in various ways |
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 BBcode macros
There is an easy way to resolve macros in ASPX or codebehind code. To resolve all the macros (recommended), use the following 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.