|
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 |
K0smiC Smarty Rookie
Joined: 23 Sep 2013 Posts: 5
|
Posted: Mon Sep 23, 2013 10:46 pm Post subject: smarty name of variable dynamic |
|
|
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 |
|
K0smiC Smarty Rookie
Joined: 23 Sep 2013 Posts: 5
|
Posted: Tue Sep 24, 2013 1:05 pm Post subject: |
|
|
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 |
|
|
|
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
|