simple load on the fly

showViewedPropImg: function() {
if(J.s(“.listing”).length == 0) {
return false
var a = J.s(“.listing”).eq(0).get().scrollTop;
var b = parseInt(J.s(“.listing”).eq(0).get().style.height);
J.g(“test_div”).down(“.list_li”).each(function(f, g) {
var e = g.down(“.dt_img img”).eq(0);
var d = e.attr(“src”);
if(typeof d === “undefined” || d == null || d.length == 0) {
var c = g.offset();
if((c.y – a) >= 0 && (c.y – a) <= (162 + b)) {
e.attr(“src”, e.attr(“data”)).removeAttr(“data”)

J.s(“.listing”).eq(0).on(“scroll”, function(d) {
if(J.g(this).down(“.list2”).length > 0) {
return false
if(c == 0) {
if(a) {
a = setTimeout(function() {
c = 0
}, 200);
c = 1

magento — remove h1 heading from cms page

how to remove the title that appears above the cms content of cms page? from the cms.xml layout file i found the code below:

just remove this line

<block type="core/template" name="page_content_heading" template="cms/content_heading.phtml"/>

[codesyntax lang=”xml”]

    <cms_page translate="label">
        <label>CMS Pages (All)</label>
        <reference name="content">
            <block type="core/template" name="page_content_heading" template="cms/content_heading.phtml"/>
            <block type="page/html_wrapper" name="cms.wrapper" translate="label">
                <label>CMS Content Wrapper</label>
                <action method="setElementClass"><value>std</value></action>
                <block type="cms/page" name="cms_page"/>


then the h1 title of all the cms page will go.but what if you want to do this only to some specific page?you have two choice,first,you can make use of magento layout update feature for cms page.

Goto menu CMS => Pages => Click the page you want to edit => Design => Layout Update XML

add the xml code below:
[codesyntax lang=”xml”]

 <reference name="content">
            <remove name="page_content_heading"/>


the other way is update the cms.xml file directly in your theme layout folder.

magento — remove “Home page” from magento cms home page

The quickest way to remove “Home page” is edit the cms home page from magento backend,and remove it from the content. you need to put a whitespace in html(&nbsp;) or you can not save it.but this way still keep the cms container html tag like:
[codesyntax lang=”html4strict”]

<div class="std"> </div>


you can remove all uneeded html tag by edit the cms.xml layout code:

[codesyntax lang=”xml”]

	    <reference name="content">
		    <remove name="cms.wrapper"/>



magento — translate words into other language for payment module

my new mangento payment module need multiple language support.Magento interface is translated with CSV localization files which was stored at the location of app/locale/[lang_folder],ie app/locale/en_us.OR you can use the built-in Inline translation tool which store the translation pair into’s much more convenience to translate via Csv localization files than the inline translation tool when you want to translate lots of string at a time.

First, i create an empty csv file named Mzcart_Pagbrasil.csv in app/locale/en_us/.I add a translation for test purpose:

“Powered by Pagbrasil”,”Powered by Pagbrasil—-”

Second,to make the new added csv localization file visible to magento, i need to update the config xml file of this module.add the config below to config.xml file under  config >> frontend path.


However,  the string “Powered by Pagbrasil” was not translated. I did clear the cache. After googling for a long time without any clue, i added a new string and it was translated,but the first string still not changed.

“Powered by Pagbrasil”,”Powered by Pagbrasil—-”        >>>>>>> still not translated.
“Please pay your order now”,”Please pay your order now@@@@@@@@@@@@”

what’s the problem?the problem is that php does not support utf8 with bom. a BOM-ed UTF-8 string will start with the three following bytes EF BB BF. php will treat this bytes as file content.this lead to the mismatch of the first string. you may find that all lang file provided by magento all encoded in utf8 without bom.

For more info you may refer to

magento — how to get Vat number/tax id

i am developing a new payment module under magento.Everything going through well as usual.However, this new payment module require a cutomer tax id. by default,magento didn’t show this field for customer.To make it available for all customer,log into magento backend, goto

System > Configuration > Customers > Customer Configuration > Create New Account Options [tab]

change the config of “Show VAT Number on Frontend” to “yes”.

so how to get the new added filed — customer vat number/taxt need to get billing or shipping model first.the code below as an example.

$billing  = $this->getOrder()->getBillingAddress();



linux — forward user email

To forward user’s email,just put an .forward file with the email addr in the user’s home diretory.If this not work for your server,Make sure the .forward file is belong to the user you want to forward email.for example,if you want to forward all email for user testuser, change current working directory to /home/testuser,touch a .forward file.

# cd /home/testuser
# touch .forward
# echo ‘’ >> .forward
# chown testuser.testuser .forward
# chmod 664 .forward

if this not work,you may check the log file located at /var/log/maillog for more info.

And keep in mind,only in a Postfix/Sendmail system it is sendmail command that utilies this file.For other situation,you may check the related document.


Linux — how to know if php run as cgi or module

For some reason you want to know how is php working with web server like apache. if you are the people who config the server,you got the answer in your head. what if you are not? well,php have a function for this:


Per php manual,call this function will returns the type of interface between web server and PHP

[codesyntax lang=”php”]



The section below is take from the php manual:
Although not exhaustive, the possible return values include aolserver, apache, apache2filter, apache2handler, caudium, cgi (until PHP 5.3), cgi-fcgi, cli, continuity, embed, isapi, litespeed, milter, nsapi, phttpd, pi3web, roxen, thttpd, tux, and webjames.

When php run in CGI mode( or any other mode other that module mode), you can not set php config via php_value directive in the .htaccess file.

you can also take a look at the phpinfo page to decide how php is working with your webserver.

zen cart — How to Add a Sidebox to Zen Cart

One of the best way to customize Zen Cart is to create a new Sidebox.A Zen Cart sidebox is what displays various contents in the left or right columns of your Zen Cart store. By default numerous sideboxes will show in either the left or right column of a Zen Cart online store. The followings are some of the most popular zen cart sidebox — The categories sidebox, the search sidebox, and the information sidebox. Zen cart comes with some builtin sidebox which could be a good tutor to start to learn how to add a new sidebox to Zen Cart.

A sidebox consists of three files which are located in the includes directory:

  1. modules/sideboxes/YOUR_TEMPLATE/new_sidebox.php
  2. languages/english/extra_definitions/YOUR_TEMPLATE/new_sidebox_defines.php
  3. templates/YOUR_TEMPLATE/sideboxes/tpl_new_sidebox.php

The ‘new’ up there should be replaced with your own sidebox name.


[codesyntax lang=”php”]

 $show_new_sidebox = true;
 if ($show_new_sidebox == true){
   $current_page_base,'sideboxes'). '/tpl_new_sidebox.php');
   //do some db query and other processing here

   $left_corner = false;
   $right_corner = false;
   $right_arrow = false;
   require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE,
   $current_page_base,'common') . '/' . $column_box_default);



[codesyntax lang=”php”]

  define('BOX_HEADING_NEW_SIDEBOX', 'Gallery');



[codesyntax lang=”php”]

 $content = <<< End_Of_Quote
  Enter your sidebox content here


linux — How to extract specified file/directory from a tar ball

well,you got a big tar ball file,but in fact you only need some special file or directory.Then you don’t want to extract  all files from the tar ball if it’s a big how to get specified file or directory from a tar ball?

tar command allows to extract a single file or directory using the following format. It works under UNIX, Linux, and BSD operating systems.

tar xvf big.tar filename
tar -zxvf abc.tar.gz directory-name
tar -zxvf abc.tar.gz path/to/directory-name -C /tmp

Keep in mind that both the filename and directory-name should be existed in the tar ball file,and the path is relative to the tar ball root.