Short Code
Short Code allows administrators to create reusable dynamic content blocks and execute them inside pages, layers, banners, product details, board content, and other iBoard-managed areas.
Use Short Code when the same content or logic needs to be reused in multiple places without copying the same HTML or code repeatedly.
Overview
A shortcode is a named reusable block. After creating a shortcode, you can call it from a page using a bracket syntax. Parameters can be passed into the shortcode and used as replaceable variables inside the shortcode content.
| Area | Description |
|---|---|
| Shortcode List | Displays registered shortcodes and allows administrators to search, edit, or delete them. |
| Shortcode Editor | Creates or updates a shortcode. |
| Usage Guide | Explains how to create and call a shortcode. |
| Examples | Shows common shortcode examples, including parameter usage and CodeDom loops. |
| AI & CodeDom | Provides a recommended AI prompt and CodeDom example for generating dynamic shortcode output. |
Shortcode List
The Shortcode List page displays existing shortcodes. Administrators can search, review, edit, or delete shortcode records.
Main Elements
| Element | Purpose |
|---|---|
| New Shortcode | Opens the Shortcode Editor to create a new shortcode. |
| Items per page | Controls how many shortcode records are displayed in the list. |
| Search | Searches shortcode records by available list data. |
| ID | Internal shortcode record ID. |
| Type | The shortcode execution type. |
| Name | The shortcode name used when calling it from a page or content area. |
| Actions | Provides available edit or delete actions. |
Shortcode Editor
The Shortcode Editor is used to create or update a shortcode. It includes the shortcode type, name, shortcode content editor, usage guide, examples, and AI / CodeDom guidance.
Editor Fields
| Field | Description |
|---|---|
| Type | Selects the shortcode type. For executable dynamic output, select Execute. |
| Name | The shortcode name. This name must match the name used when calling the shortcode. |
| Short Code | The HTML, template content, or CodeDom block that will be executed when the shortcode is called. |
| New | Clears the editor and prepares a new shortcode record. |
| Add & Update | Saves a new shortcode or updates the currently selected shortcode. |
Basic Syntax
A shortcode is called with square brackets. The shortcode name is followed by parameters.
[Execute_Test id=1 row=5 layer=radix_boxton]
In this example, Execute_Test is the shortcode name, and id, row,
and layer are parameters.
Create a Shortcode
- Open Admin > Site > Short Code.
- Click New Shortcode.
- Select the shortcode type.
- Enter the shortcode name.
- Write the shortcode content in the editor.
- Click Add & Update.
Name Example
Execute_Test
The shortcode name must match the name used inside the page or content area.
Call the Shortcode
After saving a shortcode, call it inside a page, layer, banner, product detail, or board content.
[Execute_Test id=1 row=5 layer=radix_boxton]
Parameters
Parameters are values passed into the shortcode call. Inside the shortcode content, each parameter becomes a replaceable variable.
Add # before the parameter name to use it.
| Parameter | Variable | Result |
|---|---|---|
| id=1 | #id |
1 |
| row=5 | #row |
5 |
| layer=radix_boxton | #layer |
radix_boxton |
Important Parameter Rule
Parameters must be separated by spaces.
Correct:
[Execute_Test id=1 row=5 layer=radix_boxton]
Wrong:
[Execute_Test id=1,row=5,layer=radix_boxton]
Do not separate parameters with commas. Use spaces between parameters.
Usage Guide Tab
The Usage Guide tab explains the standard process for creating and calling shortcodes. It includes the basic syntax, parameter usage, and important formatting rules.
Examples Tab
The Examples tab provides reusable shortcode examples. These examples can be copied and modified to fit your page or project.
Example 1 - Basic Output
[Execute_Test id=1 row=5 layer=radix_boxton]
ShortCode content:
<div>
ID: #id<br />
Layer: #layer
</div>
Example 2 - CodeDom Loop
This example uses the row parameter to generate repeated output.
[Execute_Test row=5 layer=radix_boxton]
ShortCode content:
<codedom>
using System;
using System.Text;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < #row; i++)
{
sb.AppendLine(string.Format("No.{0} / Layer: {1}<br />", i, "#layer"));
}
return sb.ToString();
</codedom>
Example 3 - Bootstrap Card
[Execute_Card title="Camera Finder" desc="Find the right industrial camera."]
ShortCode content:
<div class="card">
<div class="card-body">
<h5 class="card-title">#title</h5>
<p class="card-text">#desc</p>
</div>
</div>
AI & CodeDom
The AI & CodeDom tab provides a recommended prompt that can be used to generate C# CodeDom shortcode code. The generated code can be copied into the Short Code editor.
Recommended AI Prompt
Create C# CodeDom code for iBoard Shortcode Editor.
Requirements:
- Use <codedom> wrapper.
- Use StringBuilder.
- Return string.
- Receive #row parameter.
- Receive #layer parameter.
- Generate HTML output.
- Do not create controller code.
- Do not create Razor view code.
- Only generate the CodeDom block.
AI Generated CodeDom Example
<codedom>
using System;
using System.Text;
StringBuilder sb = new StringBuilder();
sb.AppendLine("<div class='shortcode-result'>");
for (int i = 0; i < #row; i++)
{
sb.AppendLine(string.Format("<div>Row {0} / Layer: {1}</div>", i, "#layer"));
}
sb.AppendLine("</div>");
return sb.ToString();
</codedom>
Recommended Workflow
- Decide where the shortcode will be used.
- Create a clear shortcode name.
- Define the parameters that the shortcode needs.
- Create the shortcode content in the editor.
- Save the shortcode.
- Call the shortcode from a page or content area.
- Preview and confirm the output.
Common Use Cases
| Use Case | Recommended Action |
|---|---|
| Reusable page block | Create a shortcode that returns a common HTML section. |
| Dynamic banner | Pass title, description, or layer parameters into the shortcode. |
| Repeated content | Use CodeDom with a loop parameter such as row. |
| Reusable Bootstrap component | Create a shortcode that outputs Bootstrap card, alert, button, or grid markup. |
| AI-assisted generation | Use the AI & CodeDom prompt and paste the generated code into the editor. |
Important Notes
- The shortcode name must match the name used in the page.
- Parameters must be separated by spaces.
- Use
#parameterNameto reference parameter values inside shortcode content. - Test shortcode output before using it on a live page.
- Be careful when using CodeDom because it executes dynamic C# code.
- Only trusted administrators should be allowed to create or edit executable shortcodes.
Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| Shortcode does not render | The shortcode name may not match the saved name. | Confirm that the saved name and the call syntax use the same name. |
| Parameter value is empty | The parameter may be missing or misspelled. | Check the shortcode call and verify parameter names. |
| CodeDom error occurs | The C# code may contain syntax errors. | Review the CodeDom block and confirm that it returns a string. |
| Output layout is broken | The generated HTML may be incomplete or missing closing tags. | Check the returned HTML structure. |
| Parameters are not parsed correctly | Parameters may be separated by commas instead of spaces. | Use spaces between parameters. |
Best Practices
- Use descriptive shortcode names.
- Keep shortcode parameters simple and predictable.
- Use lowercase parameter names when possible.
- Avoid placing sensitive logic in public-facing shortcodes.
- Document each shortcode purpose and expected parameters.
- Test CodeDom shortcodes in a safe environment before using them in production.
Shortcodes are powerful because they can reuse content and dynamic logic across multiple pages. Keep them organized and test them carefully before publishing.