Prev | Current Page 563 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

With Smarty, template
designers can also take advantage of the power of configuration files. For example,
the designer might use a configuration file for storing page titles, user messages, and
just about any other item you deem worthy of storing in a centralized location.
A sample configuration file (called app.config) follows:
# Global Variables
appName = "Example.com News Service"
copyright = "Copyright 2008 Example.com News Service, Inc."
[Aggregation]
title = "Recent News"
warning = """Copyright warning. Use of this information is for
personal use only."""
[Detail]
title = "A Closer Look..."
The items surrounded by brackets are called sections. Any items lying outside of a
section are considered global. These items should be defined prior to defining any
sections. The next section shows you how to use the config_load function to load in
a configuration file and also explains how configuration variables are referenced within
494 CHAPTER 19 ?–  T EMPLAT I NG WITH SMARTY
templates. Finally, note that the warning variable data is enclosed in triple quotes.
This syntax must be used in case the string requires multiple lines of the file.
?– Note Of course, Smarty??™s configuration files aren??™t intended to take the place of CSS. Use CSS for all
matters specific to the site design (background colors, fonts, etc.), and use Smarty configuration files for
matters that CSS is not intended to support, such as page title designations.


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