修改magento页面的title,description等------------进而可以写一个descroption数组,让description随机生成-----方便seo,节省在添加产品的时候添加descrition浪费时间
来源:互联网 发布:浙江省基层网络直报 编辑:程序博客网 时间:2024/04/30 16:31
在对用的block文件中加入:一般是content最大的block里面设定,譬如:Mage_Catalog_Block_Category_View
protected function _prepareLayout()
{
parent::_prepareLayout();
$this->getLayout()->createBlock('catalog/breadcrumbs');
if ($headBlock = $this->getLayout()->getBlock('head')) {
$category = $this->getCurrentCategory();
if ($title = $category->getMetaTitle()) {
$headBlock->setTitle($title);
}
if ($description = $category->getMetaDescription()) {
$headBlock->setDescription($description);
}
if ($keywords = $category->getMetaKeywords()) {
$headBlock->setKeywords($keywords);
}
if ($this->helper('catalog/category')->canUseCanonicalTag()) {
$headBlock->addLinkRel('canonical', $category->getUrl());
}
/*
want to show rss feed in the url
*/
if ($this->IsRssCatalogEnable() && $this->IsTopCategory()) {
$title = $this->helper('rss')->__('%s RSS Feed',$this->getCurrentCategory()->getName());
$headBlock->addItem('rss', $this->getRssLink(), 'title="'.$title.'"');
}
}
return $this;
}
例子:
protected function _prepareLayout()
{
$this->getLayout()->createBlock('catalog/breadcrumbs');
if ($headBlock = $this->getLayout()->getBlock('head')) {
if ($title = $this->getProduct()->getMetaTitle()) {
$headBlock->setTitle($title);
}
//title =name以name当title。
else{$headBlock->setTitle($this->getProduct()->getName());}
if ($keyword = $this->getProduct()->getMetaKeyword()) {
$headBlock->setKeywords($keyword);
} elseif( $currentCategory = Mage::registry('current_category') ) {
//keyword 这里写keywords
$keywords ="Replica Watches, Rolex Watches";
$headBlock->setKeywords($keywords);
// $headBlock->setKeywords($this->getProduct()->getName());
}
if ($description = $this->getProduct()->getMetaDescription()) {
$headBlock->setDescription( ($description) );
} else {
//
$zz =$this->getProduct()->getName();
//$arr1 = array($zz."111",$zz."222",$zz."333",$zz."444",$zz."555",$zz."666");
//rand descroption array!这里写要随机出来的description。
$arr1 = array(
$zz." on sale",
$zz." for sale"
);
$ss = array_rand($arr1);
//
$headBlock->setDescription($arr1[$ss]);
//$headBlock->setDescription( $this->getProduct()->getDescription() );
}
}
return parent::_prepareLayout();
}
- 修改magento页面的title,description等------------进而可以写一个descroption数组,让description随机生成-----方便seo,节省在添加产品的时候添加descrition浪费时间
- Magento修改页面Title,Keywords和Description
- 【ASP.NET】对不同产品的动态网页添加不同的title、keywords、description
- 动态修改页面的Title, Keywords and Description
- Discuz!开发之插件页面title、keywords、description等SEO设置
- title Description keyword优化 SEO
- 网站优化:title,keyword,description等重要标签SEO方法
- 获取页面的description
- [Magento] Meta Description and SEO
- 为了避免360等浏览器的页面缓存影响到系统的参数,可以在对应页面中添加随机参数。
- 在页面的title添加图标
- Magento 修改添加产品的默认属性值
- Yii如何添加title、keywords和description,简称TDK
- 标准的网站title、keywords、description写法
- Description和Title的字符长度
- 网站title/keywords/description的编写原则
- 自由编辑ZenCart的title、description、keywords
- description的覆写【数组的详细输出】
- Lucene构建网站搜索系统
- 最终我还是选择了C++
- 面试题目
- J2EE学习小结:
- 首贴
- 修改magento页面的title,description等------------进而可以写一个descroption数组,让description随机生成-----方便seo,节省在添加产品的时候添加descrition浪费时间
- 构建网络安全之加密和解密篇
- oracle学习笔记_触发器
- c# 写的一个类帮助器(动态生成类 动态类 动态属性)
- 病毒的手工排除与分析
- warning: "_POSIX_C_SOURCE" redefined
- mapxtreme java 以及 oracle 空间数据库(一)
- c++ 可变参数的使用
- Linux下的Apache和PHP安全设置