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 name of variable dynamic

 
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 -> General
View previous topic :: View next topic  
Author Message
K0smiC
Smarty Rookie


Joined: 23 Sep 2013
Posts: 5

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 Rookie


Joined: 23 Sep 2013
Posts: 5

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:   
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 -> 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