Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
smarty name of variable dynamic

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
K0smiC
Smarty n00b


Joined: 23 Sep 2013
Posts: 4

PostPosted: Mon Sep 23, 2013 10:46 pm    Post subject: smarty name of variable dynamic Reply with quote

I'm studying smarty for about two months and I find myself be in front of a problem.

I am creating a dynamic menu that reads the configuration from a file called submenu.conf in this file are:

Code:
tot_sub_menu_2 = "2"
text_sub_menu_2_1 = "Home"
text_sub_menu_2_2 = "about"


tpl file in my application I wish he would create the menu dynamically in this way:

Code:
{for $foo=1 to #tot_sub_menu_2#}

<li><a href="{#text_sub_menu_2_.{$foo}}">{#text_sub_menu_2_.{$foo}}</a></li>
{/for}


I would like to take a dynamic parameter text_sub_menu_2_1 the second loop becomes text_sub_menu_2_2 etc.

someone knows how to help me?
Back to top
View user's profile Send private message
K0smiC
Smarty n00b


Joined: 23 Sep 2013
Posts: 4

PostPosted: Tue Sep 24, 2013 1:05 pm    Post subject: Reply with quote

ok...

I found the solution.

Code:
  {for $foo=1 to #tot_sotto_menu_3#}
                                 
 {$temp_url= "sotto_menu_testo_3_"|cat:$foo}
                           
<li><a href="{$urlsotto}">{#$temp_url#}</a></li>
           
{/for}


the name of the variable loaded from the pack becomes dynamic.

ex . #sotto_menu_testo_3_1# , #sotto_menu_testo_3_2#[/code]
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General 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