- config_load method can now be called on data and template objects

This commit is contained in:
Uwe.Tews
2009-11-05 18:22:40 +00:00
parent db0767a71e
commit 5c2b897534
4 changed files with 19 additions and 28 deletions

4
README
View File

@@ -250,6 +250,7 @@ global variables.
A Smarty data object can be created as follows:
$data = new Smarty_Data; // create root data object
$data->assign('foo','bar'); // assign variables as usual
$data->conf_load('my.conf'); // load config file
$data= new Smarty_Data($smarty); // create data object having a parent link to
the Smarty object
@@ -266,7 +267,8 @@ The first parameter can be a template name, a smarty object or a data object.
Examples:
$tpl = $smarty->createTemplate('mytpl.tpl'); // create template object not linked to any parent
$tpl->assign('foo','bar'); // directly assign variables
$tpl->assign('foo','bar'); // directly assign variables
$tpl->conf_load('my.conf'); // load config file
$tpl = $smarty->createTemplate('mytpl.tpl',$smarty); // create template having a parent link to the Smarty object
$tpl = $smarty->createTemplate('mytpl.tpl',$data); // create template having a parent link to the $data object

View File

@@ -1,3 +1,6 @@
11/05/2009
- config_load method can now be called on data and template objects
11/04/2009
- added typecasting support for template variables
- bugfix on complex indexed special Smarty variables

View File

@@ -200,6 +200,19 @@ class Smarty_Internal_TemplateBase {
$this->tpl_vars = array();
}
/**
* load a config file, optionally load just selected sections
*
* @param string $config_file filename
* @param mixed $sections array of section names, single section or null
*/
public function config_load($config_file, $sections = null)
{
// load Config class
$config = new Smarty_Internal_Config($config_file, $this->smarty);
$config->loadConfigVars($sections, $this);
}
/**
* gets the object of a Smarty variable
*

View File

@@ -1,27 +0,0 @@
<?php
/**
* Smarty methode Config_Load
*
* Loads a config file
*
* @package Smarty
* @subpackage Config
* @author Uwe Tews
*/
/**
* load a config file optionally load just selected sections
*
* @param object $smarty
* @param string $config_file filename
* @param mixed $sections array of section names, single section or null
*/
function Smarty_Method_Config_Load($smarty, $config_file, $sections = null)
{
// load Config class
$config = new Smarty_Internal_Config($config_file, $smarty);
$config->loadConfigVars($sections, $smarty);
}
?>