Using BBCode in forum posts

Bulletin Board code (BBCode) is a lightweight markup language designed to let users format the text of their messages. It is used in many forums on the web, not just on websites created with Kentico. BBCode tags are similar to HTML tags and are entered in square brackets.

Users can use BBCode in forum posts only if it is enabled. You need to allow the use of BBCode for each forum or forum group:

  1. Open the Forums application.

  2. Edit a forum group or specific forum.

  3. On the General tab, navigate to the Editor settings section.

  4. Allow specific types of BBCode via the Enable options.

    Note: The Enable WYSIWYG editor option is not related to BBCode usage, and instead allows formatting of text using HTML. For security reasons, we strongly recommend leaving the WYSIWYG editor disabled for public forums.

  5. Click Save.

URLs in BBCode

All URLs in macros (URL, IMG) are validated as URLs to avoid XSS, and resolved into their absolute URL equivalents. The following URL formats can be used:

  • – URL starting with www.
  • – URL starting with protocol
  • ~/Admin/Default.aspx – virtual path
  • ../Default.aspx – relative URLs
  • /Kentico/Default.aspx – server relative URL

API for BBcode

You can resolve BBCode in custom code using the Kentico API. To resolve all BBcode macros in a string, use the following method:

string CMS.Helpers.DiscussionMacroHelper.ResolveDiscussionMacros(string inputText)

Alternatively, you can use the CMS.Helpers.DiscussionMacroHelper class to resolve macros with particular settings using the ResolveMacros method.