PHPWind門戶模式中不同欄目定義不同頭部的方法
先看pw common.php的代碼
function getAreaSrcTpl($template,$EXT='htm'){
global $db_tplstyle,$area_indextpl;
if ($template=='header' || $template=='footer') {
$srcTpl = M_P."themes/$area_indextpl/$template.$EXT";
} else {
$srcTpl = M_P."themes/$db_tplstyle/$template.$EXT";
}
if (!file_exists($srcTpl)) { //liehuo.net
global $area_indextpl;
if ($area_indextpl!='default' && file_exists(M_P."themes/$area_indextpl/$template.$EXT")) {
$srcTpl = M_P."themes/$area_indextpl/$template.$EXT";
} else {
$srcTpl = M_P."themes/default/$template.$EXT";
}
}
return $srcTpl;
}
由于使用了
if ($template=='header' || $template=='footer') {
$srcTpl = M_P."themes/$area_indextpl/$template.$EXT";
} else {
所以統一了頭部和底部,但是很多情況希望每個頻道頭部不一樣,更改方法為:
將cate.php中
require_once(M_P.'require/header.php');
改成
require_once(M_P.'require/header_cate.php');
然后復制一個header.php改名為header_cate.php;
更改require_once PrintEot('header');
為require_once PrintEot('header_cate');
然后在每個風格目錄中加上header_cate.htm,這樣就可以為每個頻道制定不同頭部了。在風格模板中