2013-04-09 137 views
0

嗨我有一個頁面ajax網站單個頁面基本上正在加載所有頁面我想根據當前視圖設置頁面標題。如何在單個頁面站點中設置頁面標題

我一直在使用這個

<title><!--TITLE--></title> 
    <? 
$pageContents = ob_get_contents(); // Get all the page's HTML into a string 
ob_end_clean(); // Wipe the buffer 

// Replace <!--TITLE--> with $pageTitle variable contents, and print the HTML 
echo str_replace ('<!--TITLE-->', $pageTitle, $pageContents); 
?> 

我已經加入標題像這樣

<li class="menu-link"> 
     <a href="index.php?page=home"><img src="images/menu/home.png" width="72" height="72" alt="Home" />Home</a> 
     <?php $pageTitle = 'Saunders-Solutions Freelance Design and Development'; ?> 
    </li> 
    <li class="menu-link"> 
     <a href="index.php?page=about"><img src="images/menu/about.png" width="72" height="72" alt="About" />About</a> 
     <?php $pageTitle = 'About Saunders-Solutions Freelance Design and Development'; ?> 
    </li> 

的網頁鏈接,但是始終顯示所有網頁上的任何幫助讚賞

相同的標題嘗試
+1

你叫'ob_start();'? – 2013-04-09 08:00:05

+0

嘗試移動ur <?php $ pageTitle = ..以上ur 標籤.. – Dinesh 2013-04-09 08:08:51

回答

0

in javascript:

document.title = "New Title"; 
0

變量$ pageTitle似乎是在用str_replace進行替換之後定義的。 也許你可以發佈更多的代碼,看看問題是什麼

0

你能打印HTML嗎? 適合我的作品。

print "<TITLE>".$pageTitle."</TITLE>"; 

然後就刪除任何設置標題其他代碼:

如:

<title><!--TITLE--></title> 
0
<? 
$TITLE[home]="Saunders-Solutions Freelance Design and Development"; 
$TITLE[about]="About Saunders-Solutions Freelance Design and Development"; 
?> 

<title><?=$TITLE[$_GET[page]]?></title> 

<li class="menu-link"> 
     <a href="index.php?page=home"><img src="images/menu/home.png" width="72" height="72" alt="Home" />Home</a>    
    </li> 
    <li class="menu-link"> 
     <a href="index.php?page=about"><img src="images/menu/about.png" width="72" height="72" alt="About" />About</a> 

    </li> 
相關問題