Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Dedicated server web hosting provided by Guru-host.eu.
Error message in conf file... best practice ?

 
Post new topic   Reply to topic    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
BenFromTokyo
Smarty Rookie


Joined: 15 Oct 2004
Posts: 12
Location: Japan

PostPosted: Fri Jan 07, 2005 9:48 am    Post subject: Error message in conf file... best practice ? Reply with quote

Hi all,
I would like to use the following pattern:

index.php:
[php:1:fc9112d864]<?php
$smarty->assign("msg_code","TOO_BIG");
?>[/php:1:fc9112d864]
message.conf:
Code:

TOO_BIG    = "The file size is limited to 10 Mb."
NO_FILE    = "Please select a file."
WRONG_TYPE = "Only SVG files please."

index.tpl:
Code:

{config_load file="messages.conf"}
{* *some magic code* *}
error = {$msg}


I would like to convert my variable {$msg_code} to {$msg} using the message.conf file...

Any idea on how to do this ?? Very Happy

Any magic would be greatly appreciated
_________________
Ben
Back to top
View user's profile Send private message
BenFromTokyo
Smarty Rookie


Joined: 15 Oct 2004
Posts: 12
Location: Japan

PostPosted: Fri Jan 07, 2005 10:42 am    Post subject: and the magic code is: Reply with quote

ok it was not so terrible:

Code:

{config_load file="messages.conf"}
{assign var=msg value=$smarty.config.$msg_code}
error = {$msg}


hope it will help somebody else...

I think it's quite a good trick finally Wink
_________________
Ben
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7047
Location: Lincoln Nebraska, USA

PostPosted: Fri Jan 07, 2005 2:55 pm    Post subject: Reply with quote

or just:
Code:
{config_load file="messages.conf"}
error = {$smarty.config.$msg_code}
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Tips and Tricks 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