飞龙博客

feilong.org

load javascripts only homepage of zencart

feilong.org 修订于2010-09-03 04:20:00 500 次浏览

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 于广州

加入收藏夹,查看更方便。

所在分类: 建站程序

新作:

旧文:

AI音乐 blog money bui 教程 echarts 教程 eclipse 教程 html css 教程 IT趋势 js 教程 json 教程 mysql 教程 nodejs npm 教程 onblog SQLite 教程 tutorials vscode 教程 wap网站 winpe启动盘 wordpress 主机推荐 人工智能 前端开发 博客 名企名网 域名注册 常用软件 建站程序 操作系统 教程 数码 无线上网 日记 电子商务 电脑笔记本 网站 网站优化 网站开发 网站推广 网站策划 网络 虚拟现实 默认