Magento去掉左栏和右栏的广告图片
Magento去掉左栏和右栏的广告图片,这个问题有很多人在问,所以分享下方法。
去掉这两个广告图片,需要我们对Magento结构的了解,左栏和右栏的内容都是在catalog.xml里控制的。在52行,去掉这个block
1 2 3 4 5 | <block type="core/template" name="left.permanent.callout" template="callouts/left_col.phtml"> <action method="setImgSrc"><src>images/media/col_left_callout.jpg</src></action> <action method="setImgAlt" translate="alt" module="catalog"><alt>Our customer service is available 24/7. Call us at (555) 555-0123.</alt></action> <action method="setLinkUrl"><url>checkout/cart</url></action> </block> |
在60行去掉这个block
1 2 3 4 | <block type="core/template" name="right.permanent.callout" template="callouts/right_col.phtml"> <action method="setImgSrc"><src>images/media/col_right_callout.jpg</src></action> <action method="setImgAlt" translate="alt" module="catalog"><alt>Keep your eyes open for our special Back to School items and save A LOT!</alt></action> </block> |
Magento的模块的调动删除,都是可以在xml中实现的。
Magento去掉URL中的index.php
Magento去掉URL中的index.php貌似对seo有一定的好处,我对这个不是很了解,正在学习seo中,呵呵。进入正题,进入后台System—>Configuration,点击左上角GENERAL中的WEB,其中有一个Search Engines Optimization,保证他是yes就好。当然前提是你的服务器支持URL重写。

Magento列表页用jQuery实现产品图片放大效果
今天看到个网站,鼠标移到列表页的产品图片上,旁边会弹出一个大图,感觉不错,就自己在Magento里写了个。先看看效果


这个效果比较好实现,打开list.phtml,把输出img那句话复制到<a>标签外面,加一个class,jQuery会用到
1 2 3 4 5 | li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>"> <img class="listhoverimg" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(300 ,327); ?>" width="300" height="327" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" /> <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(155 ,169); ?>" width="155" height="169" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" /></a> ……………………</li> |
然后在底部加上
1 2 3 4 5 6 7 8 9 10 | <script type="text/javascript"> jQuery(".listhoverimg").css("display","none"); jQuery(".products-grid li:nth-child(1),.products-grid li:nth-child(2)").addClass("img1"); jQuery(".products-grid li:nth-child(3),.products-grid li:nth-child(4)").addClass("img2"); jQuery(".products-grid .product-image").hover(function(){ jQuery(this).siblings(".listhoverimg").css("display","block") },function(){ jQuery(this).siblings(".listhoverimg").css("display","none") } ) </script> |
这个简单的Magento产品图片放大效果就出来了。
Magento安装报错
今天安装Magento时报错,报错信息是Error in file: “/home/vibramsh/public_html/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.26-0.9.27.php” – Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit in safe mode in /home/vibramsh/public_html/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.26-0.9.27.php on line 28。
出现这个报错是因为打开了安全模式,把空间的安全模式关闭就好了。
Magento限制产品名字数
Magento的产品名长短不一,有时候会影响到网站美观。有两种方法可以限定产品名的字数,一种是通过css来写的,这个就不介绍了,用起来比较麻烦,而且兼容性比较差,直接修改php文件比较简单。
一般要限制产品名字数的是list.phml这个文件了,找到名字输出的地方<?php echo $this->htmlEscape($_product->getName()) ?>,把这句改为<?php echo $this->htmlEscape(Mage::helper(‘core/string’)->truncate($_product->getName(),10,’…’)); ?>,修改数字10就能达到你要的效果。
Magento其他地方出现的产品名如果需要修改,方法是一样的。
Magento改变产品图片大小
Magento中的产品图片都是经过压缩后放到网站上的,默认的都是正方形的,而且固定大小的。我讲下Magento产品展示页的产品图片如何修改,其他的产品图片修改方法是一样的。
首先打开图片所在文件,产品展示页的是在list.phtml。找到
<img src=”<?php echo $this->helper(‘catalog/image’)->init($_product, ‘small_image’)->resize(229, 172); ?>” width=”229″ height=”172″ alt=”<?php echo $this->htmlEscape($_product->getName()) ?>” title=”<?php echo $this->htmlEscape($_product->getName()) ?>” /> 然后修改resize 和后面width,height的值。这个值要和你的图片的比例是一样的,不然会变形。
Magento产品页等页面的图片也是这样修改的。
Magento1.4添加产品报错“URL rewrite save problem”
今天在Magento1.4上添加产品时,点保存报错说是“URL rewrite save problem”。这个问题解决方法和之前写过的,Magento1.4安装完后,产品无法显示解决方法这文章的解决方法一样。打开索引,System —>Index Management 点击Select All 再直接submit。
Magento1.4打开错误提示
Magento1.4默认是把错误提示关了的,出错时Magento已经不会把具体哪个地方出错显示出来。修改方法是:把magento\errors\local.xml.sample这个文件的.sample去掉就可以了。
jQuery中cookies的应用
jQuery操作cookies,首页需要导入一个插件, 可以去官方下过来http://plugins.jquery.com/project/Cookie,下面简单的说下用法。
$.cookie(’name’, ‘value’);//设置cookie名,值
$.cookie(’name’, ‘value’, {expires: 7, path: ‘/’, domain: ‘jquery.com’, secure: true});设置cookie的名,值,有效期,路径,域,安全
$.cookie(’name’);//读取cookie的值
$.cookie(’name’, null);//删除一个cookie
Magento中的onepage页面改造
Magento中的onepage页面存在一个问题,当我们点击到第N步的时候返回到前面,就无法再直接回到第N步了,中间的内容又需要重新的输入。这个也许不叫问题,只是一个使用习惯的问题。因为有位客户需要改进这个,就改进了下。这里共享下解决方法,只要在onepage.phtml中加入以下jQuery即可
al=jQuery(".section.allow"); jQuery(".section div.step-title").click(function(){ jQuery.unique(jQuery.merge(al,jQuery(".section.allow"))); al.each(function(){ if(jQuery(this).hasClass("allow")==false) jQuery(this).addClass("allow") }) }); jQuery("#checkoutSteps button,.section div.step-title").click(function(){ stvl=setInterval (function(){ al=jQuery(".section.allow"); atidx=jQuery("#checkoutSteps>li").index(jQuery(".section.active")) if(atidx==(al.length-1) &&atidx!=0) clearInterval(stvl) },100) });
需要的可以加到自己的Magento网站中尝试下。
紫月蓝骋