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

[RESOLVIDO] Problema com a função de data

 
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 -> Language: Portuguese
View previous topic :: View next topic  
Author Message
calcio
Smarty n00b


Joined: 13 Mar 2012
Posts: 3

PostPosted: Tue Mar 13, 2012 2:19 pm    Post subject: [RESOLVIDO] Problema com a função de data Reply with quote

Primeiramente, queria saber se ainda usam esse fórum. As msgs são meio antigas. :s

Tenho o seguinte problema. tenho um um arquivo de tradução que contem arrays. algo do tipo
Code:

$lang = array(
               title => 'nome do site',
               month => array(
                    'january' => 'janeiro',
                    'February' => 'fevereiro')
           );


E assim por diante. Tenho esse scripts de tradução e preciso usar esses meses no smarty usando o {section} ou {html_select_date}, ou seja, os meses devem ser trduzidos de acordo com o array de mês.

Eu tentei algumas maneiras mas nenhuma delas funcionou, alguém pode dar uma ideia?

Estou utilizando o CodeIgniter como framework e o smarty para gerar os views.
Back to top
View user's profile Send private message
calcio
Smarty n00b


Joined: 13 Mar 2012
Posts: 3

PostPosted: Tue Mar 13, 2012 4:40 pm    Post subject: Reply with quote

Finalmente consegui resolver uma parte do problema. Bastou eu fazer assim:

Code:

{foreach from=$trans.month item=month}
    {$month}<br />
{/foreach}


Onde $trans é a var gerada pelo CI para pegar o array do arquivo de tradução.

Infelizmente os exemplos q se ve do smarty são básicos e ñ cobrem mnt a vida real.
Back to top
View user's profile Send private message
calcio
Smarty n00b


Joined: 13 Mar 2012
Posts: 3

PostPosted: Tue Mar 13, 2012 5:13 pm    Post subject: Reply with quote

Resolução final...
Criei um array indexado por número para ser incluído em um select de um form. Então o foreach ficou assim:

Code:

<select name="month" id="month">
    <option value=""></option>
{foreach from=$trans.monthByNum key=num item=month}
   <option value="{$num}">{$month}</option>
{/foreach}
</select>
Back to top
View user's profile Send private message
migas
Smarty Regular


Joined: 07 Apr 2004
Posts: 73
Location: Porto, Portugal

PostPosted: Mon May 07, 2012 9:17 pm    Post subject: Reply with quote

Aqui fica mais uma dica. Wink

Code:
<select name="month" id="month">
    <option value=""></option>
{html_options options=$trans.monthByNum selected=$Mes_a_Escolher}
</select>
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 -> Language: Portuguese 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