在对用的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-ce-2.4.0-2020-07-24-11-15-38.tar.gz 不带sample data
Ajax-magento2-catalog-infinite-scroll.zip,免费的Magento 2扩展,为目录添加无限滚动功能(通过AJAX实现)编码教程,ajax代表异步javascript和xml。它是多种web技术的集合,包括html、css、json、xml和javascript。...
因为国外网速太慢了,所以下载后分享给需要的人。magento-ce-2.4.2-p1-2021-04-22-10-49-09
magento-1.9.1.1-2015-04-30-12-49-08 源代码包
Ajax-Magento-ajax-add-to-cart.zip,[模块magento 1]magento ajax添加到购物车-ajoter vos produits au panier en ajax/感谢ajax将您的产品添加到购物车,ajax代表异步javascript和xml。它是多种web技术的集合,包括...
适应于 magento1.9.x ================================== 分类的网址达到短路径: http://local.router-switch.com/Price-cisco-router-cisco-router-1900-series_c11 普通搜索 ... 高级搜索 ...对路径都做到短路径,对...
Magento-PSR-0-Autoloader, 这个扩展增加一个 PSR 0自动装弹机在Magento自动装弹机前 Magento-PSR-0-Autoloader这个扩展在Magento自动装弹机前添加一个 PSR-0 自动装弹机要初始化新的命名空间,请在 local.xml的...
Ajax-magento2-ajax-layered-navigation.zip,ajax分层导航magento 2提供了一个过滤器列表,帮助您的客户以最短的方式搜索和获得他们最喜欢的产品。这个扩展应用了现代ajax技术来增强过滤系统,以提高用户对页面上每...
客户可以很容易地选择可配置的选项并在弹出窗口中编辑项目,而不会浪费重新加载页面的时间。,ajax代表异步javascript和xml。它是多种web技术的集合,包括html、css、json、xml和javascript。它用于创建动态网页,...
添加设置页面的Canonical Meta属性,让页面更加权威(其他同页面301过来)。 比较完美的控制nofollow和robot 附带的针对GOOGLE xml站点地图的优化,支持100k+的产品 根据模版自定义产品页面的标题、关键词和...
这个项目的目的是让能够安装 Magento 模块,并自动将它们集成到 Magento 安装中。 我们强烈建议您同时阅读上的通用作曲家文档 您还应该看到 项目详情 该项目仅涵盖 composer 的自定义安装程序。 如果你有过时版本...
magento2-blog-module-tutorial, 关于如何从头开始创建 magento 2模块的教程,带有测试 2博客模块教程这个模块是 WIP,它将被更新为每个教程我目前正在写。介绍如何从头创建完整功能的Magento 2模块。 即使有测试,...
深入理解Magento-第一章 – Magento强大的配置系统 深入理解Magento-第二章 – Magento请求分发与控制器 深入理解Magento-第三章 – 布局,块和模板 深入理解Magento-第四章 – 模型和ORM基础 深入理解...
Magento-Vagrant-Puppet-Nginx 安装次数 Magento MySQL PHP PHP-FPM Nginx的 n98-玛格伦 设置 git submodule init git submodule update vagrant up 修改人偶/清单/base.pp class { "magento" : install_...
最新版本的官网下载的magento压缩包。内含样本数据。直接解压即可。属于二次开发的电商网站。请多多交流指教
在Magento 2站点内安装要在您的Magento 2项目中使用,可以使用: composer require --dev magento/magento-coding-standard 出于安全考虑,以这种方式安装时,无法自动添加phpcs的Magento标准。 您可以通过将以下...
magento2-checkout-success-misc-script-源码.rar
magento2-developer-quickdevbar, Magento2的开发人员工具栏 Magento2开发人员工具栏 希望这个调试工具栏能够加速Magento2开发模块。 如果你想改进这个工具栏的任何反馈和想法,那么你可以通过GitHub上的追踪器...
magento批量定义realter crosess-sell up-sell三种类型商品关联的插件
第一章Magento 销售 1.订单管理-----------------------------------------------------Magento-2.1订单管理 2.发票---------------------------------------------------------- Magento-2.2订单管理 3.配送-------...