Netbiscuits XHTML to BBcode conversion

This "Dreamweaver Function Source" converts SDL Tridion XHTML (from a Rich Text Field) into BBcode understood by Netbiscuits.

BBcode

BBCode or Bulletin Board Code is a lightweight markup language used to format posts in many message boards. Netbiscuits also uses it to format its rich text in their BiscuitML. More on the use of BiscuitML can be found in the article Go Mobile with SDL Tridion 2011 and Netbiscuits.

Through Tridion Modular Templates we can use Custom Functions to add to the Dreamweaver Template �language�, This extension will add the following two Custom Functions:

  • RenderComponentFieldAsBBCode(fieldname, fieldIndex)

  • RenderComponentFieldAsBBCode(fieldname, fieldIndex, outputImages)

Using this extension

The following are examples of how you can use this extension in your Dreamweaver templates:

Convert RTF to BBCode without images

@@RenderComponentFieldAsBBcode("body", 0)@@

Convert RTF to BBCode with images

@@RenderComponentFieldAsBBcode("body", 0, true)@@

Differences from default DW Behavior

Basically the two methods are called instead of the RenderComponentField() call and will convert your (X)HTML into BBcode, optionally with images (you might want to omit images from a Rich Text Field as BiscuitML will not transform them for the requesting device, so the easiest solution is to just not output them and output them in a image widget. 

Installing this extension

To enable this extension you will need to: 

  1. Add the "Templating.Expression.NetbiscuitsFunctions.dll" file to your Content Manager�s GAC (Global Assembly Cache)
  2. Register it with the Tridion Template Engine by adding it to the file [Tridion]\Config\Tridion.ContentManager.Config

Adding it to the Global Assembly Cache

You can add the assembly to the Assembly Cache by executing:

gacutil.exe /i Templating.Expression.NetbiscuitsFunctions.dll

Registering the Extension with the Tridion Template Engine

Edit the file [Tridion]\Config\Tridion.ContentManager.Config.

Towards the end of this file you will find a section named �function Sources�. Add the highlighted line below to your configuration file:

<functionSources>
  <functionSource type="Tridion.ContentManager.Templating.Expression.BuiltInFunctions"/> 
  <functionSource type="Templating.Expression.NetbiscuitsFunctions"
                    assembly="Templating.Expression.NetbiscuitsFunctions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1dc42e7505ed5ba7, processorArchitecture=MSIL"/>
</functionSources>

Make sure that this file is still well-formed after you edit it.

You will have to restart the Tridion Content Manager COM+ server, the Tridion Publisher and the Tridion Template Builder before you can use this extension.

This extension is created for version SDL Tridion 2011 SP1. 


Developer
:    Bart Koopman
Company
License agreement
Tags
:    Netbiscuits
Version
:   1.0
Source
:   Yes

About the Author
Bart Koopman
Community Development Consultant

As a Community Development Consultant, Bart is the evangelist of all SDL Tridion products. Bart used to be a consultant and trainer at SDL Tridion, supporting both partners and customers with their implementations.

SDL CMT division