2013-04-24 92 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