Creating a Named Template

When using a Bright shortcode, there are two models for the template:

  • inline
  • by-name

An inline template is of the format

[bright]
My Inline Template
[/bright]

Where as a named template is of format

[bright template=template-name]

A final slash is optional for WordPress shortcodes

[bright template=template-name/]

If you use inline templates, or WordPress is in any way injecting whitespace into your rendered templates, we strongly recommend you install the Don’t Muck My Markup plugin, and enable it for any post where you see this behavior.

When creating a named template, often you want to capture the text of an existing template. Please see the section here on how to capture the text of an existing named template into an inline template. You can also capture that text to create a new modified template with a new name, as shown below.

If you have an inline template, you can convert it to a named template by two methods:

  • adding it in PHP via a plugin or the functions.php file for your theme. This is described here.
  • adding it as a named template through the Bright Admin Tool.

To do this navigate to the Bright admin tool, select the Edit Templates, and click the + symbol.

Give your template a name, enter your template text and click save.

You may now use this name across your site using the model

[bright type... name=the name you gave your template in the Bright Admin Tool]

Creating your own named template allows you to modify the stock templates, and remove or add elements. For example just removing the img tag from the Bright classic template is an effective way to create a template version with no image. A reasonable name for such a template would be class-no-image, for example. So wherever on the site you want the classic template with no image, you would just use an embedder like:

[bright type=course template=classic-no-image]

See the following document if you\'d like to copy and/or alter the text of a template available on your site, but not in the Admin Template Menu.

Capturing the Text of An Existing Template

$bright = \Bright\Wordpress::getInstance();

$mytemplatecode = ;
$bright->addTemplate('my-template-name',$mytemplatecode);