/
ft_eval_smarty_string.html
38 lines (32 loc) · 1.43 KB
/
ft_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
---
layout: default
navPage: docs
heading: ft_eval_smarty_string
breadcrumbs:
- Module Development,/module_development/
- Form Tools 2,/module_development/index_ft2/
- Helper Functions,/module_development/helper_functions/
- ft_eval_smarty_string
prev: ft_display_module_page,/module_development/ft_display_module_page/
next: ft_get_dhtml_page_nav,/module_development/ft_get_dhtml_page_nav/
categories: module_development
---
{% include open_section.html nav='nav_module_development.html' selected='ft_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 = ft_eval_smarty_string($L["phrase_num_settings_to_complete"], $placeholders);
echo $string; // "You have 5 settings to complete."
{% endcodemirror %}
{% include close_section.html %}