TAILIEUCHUNG - Beginning PHP and Postgre SQL E-Commerce From Novice to Professional phần 2

Cách tiêu chuẩn để tạo và cấu hình một trang Smarty là thể hiện trong đoạn mã sau đâyHatShop, chúng tôi tạo ra một trang lớp có tên là được thừa kế từ Smarty, trong đó có các thủ tục khởi tạo trong constructor của nó. Điều này làm cho làm việc với các mẫu Smarty dễ dàng hơn. | 42 CHAPTER 2 LAYING OUT THE FOUNDATION S The standard way to create and configure a Smarty page is shown in the following code snippet php Load the Smarty library require_once SMARTY_DIR . Create a new instance of the Smarty class smarty new Smarty smarty- template_dir TEMPLATE_DIR smarty- compile_dir COMPILE_DIR smarty- config_dir CONFIG_DIR In HatShop we created a class named Page that inherits from Smarty which contains the initialization procedure in its constructor. This makes working with Smarty templates easier. Here s again the code of the Page class class Page extends Smarty Class constructor public function __construct Call Smarty s constructor parent Smarty Change the default template directories this- template_dir TEMPLATE_DIR this- compile_dir COMPILE_DIR this- config_dir CONFIG_DIR Note The notion of constructor is specific to object-oriented programming terminology. The constructor of a class is a special method that executes automatically when an instance of that class is created. In PHP the constructor of a class is called_construct . Writing that code in the constructor of the Page class guarantees that it gets executed automatically when a new instance of Page is created. The Smarty template file except for a few details contains simple HTML details are worth analyzing. In before the HTML code begins the configuration file is loaded. smarty config_load file CHAPTER 2 LAYING OUT THE FOUNDATION S 43 Tip Smarty comments are enclosed between and marks. At this moment the only variable set inside the file is site_title which contains the name of the web site. The value of this variable is used to generate the title of the page in the HTML code DOCTYPE html PUBLIC - W3C DTD XHTML EN http TR xhtml11 DTD html head title site_title title link href type text css rel stylesheet head Variables that are loaded from the config files are .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.