/
eval_smarty_string.html
39 lines (33 loc) · 1.46 KB
/
eval_smarty_string.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
layout: default
navPage: docs
heading: General::evalSmartyString()
breadcrumbs:
- Module Development,/module_development/
- Form Tools 3,/module_development/ft3/
- Helper Methods,/module_development/ft3/helper_methods/
- General::evalSmartyString()
prev: Modules::loadModuleField(),/module_development/ft3/load_module_field/
next: General::getDhtmlPageNav(),/module_development/ft3/get_dhtml_page_nav/
categories: module_development
versions: FT3
---
{% include open_section.html nav='nav_module_development_ft3.html' selected='eval_smarty_string' nav_width=4 %}
<p>
This is a powerful function that can process any string as a Smarty template, returning the string result.
The way it works is quite simple. You pass the string containing the Smarty logic / variables, and a list of
placeholders and their replacement values. It does the task of parsing the Smarty string and returning the
result. Here's an example. Imagine your language file contained this rule:
</p>
{% codemirror php %}
$L["phrase_num_settings_to_complete"] = "You have {\$num_settings} settings to complete.";
{% endcodemirror %}
<p>
Then, you can process that string to replace the $num_settings Smarty variable like so:
</p>
{% codemirror php %}
$placeholders = array("num_settings" => 5);
$string = General::evalSmartyString($L["phrase_num_settings_to_complete"], $placeholders);
echo $string; // "You have 5 settings to complete."
{% endcodemirror %}
{% include close_section.html %}