Merge branch 'master' into recurring-activity-46
[civicrm-core.git] / CRM / Core / Smarty / plugins / block.crmScope.php
CommitLineData
9915ae36
TO
1<?php
2
3/**
4 * Smarty block function to temporarily define variables.
5 *
6 * Example:
7 *
8 * @code
9 * {tsScope x=1}
10 * Expect {$x}==1
11 * {tsScope x=2}
12 * Expect {$x}==2
13 * {/tsScope}
14 * Expect {$x}==1
15 * {/tsScope}
16 * @endcode
17 *
77b97be7
EM
18 * @param array $params must define 'name'
19 * @param string $content Default content
20 * @param object $smarty the Smarty object
21 *
22 * @param $repeat
9915ae36
TO
23 *
24 * @return string
25 */
26function smarty_block_crmScope($params, $content, &$smarty, &$repeat) {
17f267d6 27 /** @var CRM_Core_Smarty $smarty */
9915ae36
TO
28
29 if ($repeat) {
30 // open crmScope
17f267d6 31 $smarty->pushScope($params);
9915ae36
TO
32 }
33 else {
34 // close crmScope
17f267d6 35 $smarty->popScope();
9915ae36
TO
36 }
37
38 return $content;
39}