load javascripts only homepage of zencart
feilong.org 修订于2010-09-03 04:20:00 288 次浏览Where should I put javascript files within my Zen Cart template that ONLY Main Page loads?Feilong searched in zencart.com,and figured it out.
The best test for homepage is a variable introduced in zencart v1.3.7 called $this_is_home_page. It always return true on Homepage and return false elsewhere.
1.Below is feilong's coding js only for homepage in yourtemplate/common/html_header.php of zencart:
/* refer to http://feilong.org/load-javascripts-only-homepage-zencart 20100903 shenzhen china */
if($this_is_home_page) {$homejsname='home_fl.js';//feilong tip:you can change the name
echo '<script type="text/javascript" src="' . $template->get_template_dir('.js',DIR_WS_TEMPLATE, $current_page_base,'jscript') . '/' . $homejsname . '"></script>'."\n";//'jscript' is the directory where the js files you want to place.
}
2.Feilong note:place home_fl.js in includes/templates/YOURTEMPLATE/jscript/
3.Enjoy.
更新网址:https://feilong.org/load-javascripts-only-homepage-zencart
最初发布:20100903 04:20:00 feilong.org 于广州
加入收藏夹,查看更方便。
所在分类: 建站程序
新作:load js files for special page in template directory of zencart