2013-04-24 96 views
1

在我的magento商店有一個小問題。我創建了一個名爲黃金的頁面標題。本頁面包含n個產品數量。如果客戶點擊產品,則將頁面標題名稱更改爲產品名稱如何將頁面標題名稱更改爲magento中的產品名稱?

有沒有可能改變它。我在php中解決了這個問題。但在magento沒有運氣。

這裏是php代碼。

<?php 
ob_start(); // Buffer output 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 

<head> 
<title>Test</title> 
</head> 

<body> 
<?php 
$pageTitle = 'New Test'; // Call this in your pages' files to define the page title 
?> 
</body> 
</html> 
<?php 
$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 ('Test', $pageTitle, $pageContents); 
?> 

感謝

回答

1

在Magento您可以更改頁面標題是這樣的:

$headBlock = $this->getLayout()->getBlock('head'); 
$headBlock->setTitle($newtitle); //set title 
$headBlock->setKeywords($keywords); //set keywords 
$headBlock->setDescription($description); //set description