|
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 |
Yegg Smarty Rookie
Joined: 16 Sep 2003 Posts: 6
|
Posted: Fri Jan 21, 2005 2:14 am Post subject: How to change name of Config VAR |
|
|
e.g. I have a config file - where defined some config vars liks
page_title_1="1'st page"
page_title_2="2'd page"
page_title_3="3'd page"
and I have some page id 1, 2 or 3.
in template I want to use code like this:
{#page_title_{$page_id}#}
how to make it working? _________________ Sorry, for my bad english. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Jan 21, 2005 3:17 pm Post subject: |
|
|
You can use sections:
config file:
Code: | [1]
page_title = 1st page
[2]
page_title = 2nd page
[3]
page_title = 3rd page |
template:
Code: | {config_load file="my.conf" section=$page_id}
{#page_title#} |
|
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
|
Back to top |
|
Yegg Smarty Rookie
Joined: 16 Sep 2003 Posts: 6
|
Posted: Sat Jan 22, 2005 11:33 am Post subject: |
|
|
tnx alot _________________ Sorry, for my bad english. |
|
Back to top |
|
Sjefen Smarty Rookie
Joined: 01 Apr 2006 Posts: 19
|
Posted: Tue Apr 04, 2006 7:05 pm Post subject: Hm |
|
|
I'm trying this sollution, in a template where I loop through an array: {foreach from=$menu item="entry"}. The array elements are displayed with $entry.alt.
When I try getting the variable from the config, for each iteration of the for loop, file like this:
{config_load file="my.conf" section=$entry.alt}
{#page_title#}
I get no result. I checked by replacing "$entry.alt" with the section name (which it should containt), which worked. But using "$entry.alt" won't.
Any ideas? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri Apr 21, 2006 5:18 pm Post subject: |
|
|
Just saw this post.
Please verify that $entry.alt really is the section name. It seems it is not. |
|
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
|