Code Blocks

Code Blocks are used in the editor to include scripts and other code in content, allowing it to be visible and editable, without the need to ue the Code Editor to do so.

All the Code Block options are disabled by default for security reasons, and can be enabled in Editor Profiles -> Editor Parameters -> Advanced.

Caution: 
Enabling any of the Code Block options will allow users of the editor to create content and effect changes to the site - directly or indirectly - that could present a security risk to the site and its visitors. These options should therefore only be enabled in profiles assigned to trusted users and user groups.

Managing code with Code Blocks

Code - <script>, <style>, <?php?>, custom <xml> or {shortcode} - can be inserted into the editor by copying it from its source and pasting it into the editor, or by dragging & dropping it into the editor window.

A new Code Block will then be created at the point the code was inserted. The code can be edited as if it were plain text, although none of the editor toolbar formatting, eg: Bold, Underline etc. can be applied to the text

Pressing Enter will create a new line in the Code Block, and pressing Tab will create an indent.

 

To move out of a Code Block into a new paragraph below it, press SHIFT + Enter.

To delete a code block, select all the text inside the block and press the Backspace key twice.

Creating new Code Blocks

A new empty Code Block can be created by selecting the required type - script, style, php, xml, shortcode - from the Format list.

A Code Block should include the tags that define its type, eg: <script type="text/javascript"> or <style type="text/css">. If these are not included in a Code Block, then the relevant tag - without attributes - will be added when the content is saved.