load javascripts only homepage of zencart
飞龙更新于 2010-09-03 04:20 加入书签 CTRL+D 有 52 个朋友来过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.
维护小站,感谢赞赏。
联系飞龙,请转淘宝。
飞龙初发:
2010-09-03 04:20
本文更新网址:
https://feilong.org/load-javascripts-only-homepage-zencart
所在目录: 建站程序
新作:load js files for special page in template directory of zencart