RE: [SMARTY] Accessing values from config files indirectly {#$var#} ?
| From: | Thomas Akkermans | Date: | Fri, 26 Apr 2002 12:42:12 +0000 |
| Subject: | RE: [SMARTY] Accessing values from config files indirectly {#$var#} ? | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-3897@lists.php.net to get a copy of this message | ||
I had the same problem. I solved it with a custom function:
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: conf_var
* Purpose: dynamically use vars from the configfile
* -------------------------------------------------------------
*/
function smarty_function_conf_var($params, &$this)
{
echo $this->_config[0]["vars"][$params["name"]];
}
?>
In your template use this:
{conf_var name=$section}
> -----Original Message-----
> From: Michal Prinke [mailto:bogien@conecto.pl]
> Sent: vrijdag 26 april 2002 14:47
> To: smarty-general@lists.php.net
> Subject: [SMARTY] Accessing values from config files
> indirectly {#$var#} ?
>
>
> Let's say I have such a configuration file "section_titles.conf":
> users = "Listing of our users"
> poll = "A little questionnaire for all of you"
> login = "Type your login & password here"
>
>
> Then, I pass a variable "section" to the template:
> $smarty->assign("section", "users");
> $smarty->display();
>
>
> ...and I want to echo full section title:
> <html>
> <body>
> <h1>{#$section#}</h1>
> <p>blah blah blah
> </body>
> </html>
>
>
> BUT! - The {#$section#} construct does not work:
> Warning: Smarty plugin error: unknown tag - '#$subject#'
>
>
> How to fix it?
> Thanks...
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>