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

Smarty migration from 2 to 3: How to include part after dot?

 
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 -> Smarty Development
View previous topic :: View next topic  
Author Message
wadi
Smarty n00b


Joined: 02 Oct 2008
Posts: 2

PostPosted: Fri Mar 11, 2016 9:02 pm    Post subject: Smarty migration from 2 to 3: How to include part after dot? Reply with quote

Hello

I have a big project that uses smarty for years and am now in the process of upgrading from Smarty 2 to Smarty 3. I use a custom function for i18n:
Code:

function smarty_function_gettd($params, &$smarty)
{
    $lang = $smarty->getTemplateVars()['ilang'];
    $text_id = $params['t'];
    return Utility::getText($lang, $text_id, $params, $escape);
}

With this implementation, I an use the following in my templates:
Code:

{gett footer}

and it will read the text for id footer in the language of the user. So far so good. With smarty that worked for ids that have dots in them, for example the following:
Code:

<span><a href="contact/">{gett footer.contact}</a></span>
<span><a href="imprint/">{gett footer.imprint}</a></span>

would be the way for our project to cluster language id together into groups that make sense.

Now when I upgrade my code base to use Smarty 3 instead of 2, it turns out that when for example {gett footer.contact} is called, only footer gets passed on as parameter and not the complete footer.contact. Somehow everything after the dot (including the dot itself) is cut of.

I have no idea, why this happens. My guess is that is has something to do with the new way, Smarty parses the templates.

My question: Why is this happening and what would be a possible way to fix it (without having to rewrite tons of templates using the dot notation for the ids).
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 -> Smarty Development 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