The "HTML Content" feature allows you to store HTML or Smarty content that can be inserted into any template using a tag. You may also see HTML content referred to as "includes". This is useful for common blocks of branded content such as headers or footers that will often be the same across many templates.
You can call HTML Content into any template using the following tag:
{include 'content:contentKey'}
Replace "contentKey" with the key name you gave the content in the system.
For example: Let's assume you have 2 blocks of content; "Header" with the key = "header1" and "Footer" with the key = "footer1".
You may include more than one block of HTML Content:
{include 'content:header1'} Unique body content for this template here {include 'content:footer1'}
The include is useful when you have many templates referencing the same centralized HTML content. Any edits to the content within the include will cascade across all templates where that content is included.
Using the Scope parameter
If you define Smarty variables in an include, and wish to render them in the message template, you will need to use the Scope parameter. Setting the scope parameter to parent will place the HTML content include at the top of the template hierarchy, making it accessible to subsequent variables and functions.
Additionally, we assign the HTML output to a variable called blackhole. This variable is never used, which means, we will not use the HTML output of the Include, only the $data variable that is built up.
Example where the variable is defined in the HTML content:
HTML Content with a key of "header":
{$greeting = "Hello World"}
Message template that includes the HTML Content:
{include 'content:header' scope='parent' assign='blackhole'} {$greeting}
Rendered Output:
Hello World
Comments
0 comments
Please sign in to leave a comment.