我有一個關於如何動態更改要在網頁中顯示的內容的問題。 我有幾個固定的網站部分 - 標題,導航,頁腳,飛濺和邊欄。使用PHP的動態導航包括
我只希望我的網站的中間部分根據菜單鏈接改變用戶點擊的內容。
下面是我的index.php代碼
<?php
include "/templates/header.php";
include "templates/menu.php";
include "/templates/splash.php";
$action = "index";
$disallowed_paths = array('header','menu','splash','bottom_page', 'footer');
if (!empty($_GET['action']))
{
$tmp_action = basename($_GET['action']);
if (!in_array($tmp_action, $disallowed_paths) && file_exists("/content/$tmp_action.php"))
$action = $tmp_action;
}
include "/content/$action.php";
include "/templates/bottom_page.php";
include "/templates/footer.php";
?>
我menu.php包含首頁鏈接,關於,產品,服務和登錄鏈接 我只是想將main_index.php改爲include
以上基於wh在用戶點擊。
請指教,如果這種方法是好的。 或者我應該創建類似的文件作爲的index.php多次使用包括對每個文件按鏈接菜單上點擊
看看智者或simular模板系統,以更好地理解 – donald123