Prev | Current Page 564 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"


config_load
Configuration files are stored within the configs directory and loaded using the
Smarty function config_load. Here??™s how you would load in the example configuration
file, app.config:
{config_load file="app.config"}
However, keep in mind that this call will load just the configuration file??™s global
variables. If you??™d like to load a specific section, you need to designate it using the
section attribute. So, for example, you would use this syntax to load app.config??™s
Aggregation section:
{config_load file="app.config" section="Aggregation"}
Two other optional attributes are also available, both of which are introduced here:
scope: Determines the scope of the loaded configuration variables. By default, this is
set to local, meaning that the variables are only available to the local template. Other
possible settings include parent and global. Setting the scope to parent makes the
variables available to both the local and the calling template. Setting the scope to
global makes the variables available to all templates.
section: Specifies a particular section of the configuration file to load. Therefore,
if you??™re solely interested in a particular section, consider loading just that section
rather than the entire file.
Referencing Configuration Variables
Variables derived from a configuration file are referenced a bit differently than other
variables.


Pages:
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576