This is a continuation of the basic installation, please read that first!
此處網頁是 basic installation,的延伸,所以在閱讀此網頁前請先研讀上個網頁!
A slightly more flexible way to setup Smarty is to extend the class and initialize your Smarty environment. So instead of repeatedly setting directory paths, assigning the same vars, etc., we can do that in one place. Lets create a new directory "/php/includes/guestbook/" and make a new file called setup.php. In our example environment, "/php/includes" is in our include_path. Be sure you set this up too, or use absolute file paths.
安裝 Smarty 的另外一種更有彈性的方法是延伸類別檔後再初始化 Smarty 環境,如 此一來我們不必重複設定檔案目錄,而可以一次就設定好要替換的參數、指定相同的變數等等之 類的。我們先建立一個新的目錄 "/php/includes/guestbook/" 且編輯一個新的檔案名為 setup.php。在我們的示範環境中,"/php/includes" 在我們的 include_path 設定中。請確定你也有一 樣的設定,不然的話請使用絕對路徑。
Now lets alter the index.php file to use setup.php:
現在我們改變我們的 index.php,設定其使用 setup.php:
Now you see it is quite simple to bring up an instance of Smarty, just use Smarty_GuestBook which automatically initializes everything for our application.
現在我們可以知道要實作出一個 Smarty 是相當容易的,只要在應用程式的初始時使 用 Smarty_GuestBook 就可以了。