Sử dụng hàm quá tải giao diện để thay đổi tiêu đề
Một Drupal project gần đây, có một yêu cầu là làm trang báo giá. Tôi sử dụng hai module filebrowser và IMCE để giải quyết vấn đề.
1. IMCE cung cấp tính năng để người điều hành quản lý các tập tin trong một/nhiều thư mục. Đối với site này tôi chọn thư mục /sites/domain.com/files/bao-gia/ làm thư mục chứa các tập tin văn bản báo giá.
2. Filebrowser cung cấp các trang liệt kê cấu trúc thư mục/tập tin của một số path mà người điều hành có thể định trước. Đương nhiên, lúc này, tôi sẽ tạo một trang liệt kê cấu trúc tập tin/thư mục cho /sites/domain.com/files/bao-gia
Sự kết hợp không hoàn hảo, vì tiêu đề trang mà module filebrowser tạo ra quá xấu: "Displaying contents of directory %dir".
Trong khi tôi cần tiêu đề ngắn gọn: "Báo giá".
Cảm ơn tính năng quá tải giao diện của PHPTemplate. Tôi tạo một module cực kỳ đơn giản như sau:
/sites/domain.com/modules/customize/
/sites/domain.com/modules/customize/customize.info
/sites/domain.com/modules/customize/customize.module
File customize.info
; $Id: customize.info 303 2008-10-20 05:06:45Z The Hong $ name = Customize description = A helper module for customizing SimTan's site. package = @Demand Vision core = <a href="http://toila.net/category/drupal-version/6x.html">6.x</a>
File customize.module
<?php
/**
* Customize <a href="http://toila.net/taxonomy/term/161">theming</a> function for filebrowser page, just to
* change the page title
*
*/
function <a href="http://toila.net/category/t%E1%BA%A1p-ghi/php.html">php</a>template_filebrowser_page ($files, $header, $total_size) {
if (arg (0) === 'bao-gia') {
<a href="http://toila.net/category/t%E1%BA%A1p-ghi/drupal.html">drupal</a>_set_title ('Báo giá');
}
return theme_filebrowser_page ($files, $header, $total_size);
}
?>Kết quả như ý muốn
:-)
Thế Hồng
Unsigned version
20 hours 27 min ago
20 hours 27 min ago
1 day 22 hours ago
2 days 9 hours ago
2 days 23 hours ago
5 days 23 hours ago
6 days 3 hours ago
1 week 1 day ago
1 week 1 day ago
2 weeks 11 hours ago