|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
TheSunMan Smarty n00b
Joined: 22 Feb 2019 Posts: 2
|
Posted: Fri Feb 22, 2019 6:19 pm Post subject: get Raw Content in Block Function |
|
|
Hello,
is there any way to get the Raw Content here?
Template:
Code: |
{t name="welcome"}Hello {$me->getFirstname()}, how are u?{/t}
|
Function:
Code: |
function translation($params, $content, Smarty_Internal_Template $template, &$repeat)
{
if (!$repeat) {
// $content is already "Hello Phil, how are u?" here
return $content;
}
}
|
In other Words: I want to use the Smarty Placeholder in my Translation Table, so I dont need to split every Single Word.
Is there any Way to change the Priority of my block Function, before the Template vars getting Compiled?
Thanks. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri Feb 22, 2019 7:21 pm Post subject: |
|
|
Use a different placeholder.
Or think your approach through more carefully. |
|
Back to top |
|
TheSunMan Smarty n00b
Joined: 22 Feb 2019 Posts: 2
|
Posted: Fri Feb 22, 2019 8:16 pm Post subject: |
|
|
ty
well that was easy:
Code: |
function translation($params, $content, Smarty_Internal_Template $template, &$repeat)
{
if (!$repeat) {
$content = \Core\Translation::get($params['namespace'] ?: "", $params['name'], $content, $params['lang'] ?: "de");
if (stripos($content, '{$') !== false) {
$content = $template->smarty->fetch('eval:' . $content);
}
return $content;
}
}
|
just need to use {literal} in template File...
Code: | {t name="welcome"}Hello {literal}{$me->getFirstname()}{/literal}, how are u?{/t} |
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat Feb 23, 2019 1:02 am Post subject: |
|
|
I would suggest string: vs. eval: unless you actually explicitly want to avoid caching. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|