Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

get Raw Content in Block Function

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
TheSunMan
Smarty n00b


Joined: 22 Feb 2019
Posts: 2

PostPosted: Fri Feb 22, 2019 6:19 pm    Post subject: get Raw Content in Block Function Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri Feb 22, 2019 7:21 pm    Post subject: Reply with quote

Use a different placeholder.
Or think your approach through more carefully.
Back to top
View user's profile Send private message
TheSunMan
Smarty n00b


Joined: 22 Feb 2019
Posts: 2

PostPosted: Fri Feb 22, 2019 8:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat Feb 23, 2019 1:02 am    Post subject: Reply with quote

I would suggest string: vs. eval: unless you actually explicitly want to avoid caching.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP