广州传奇网络

地址:广州市天河区东圃大马路富华楼C座

电话:13808825895

邮箱:gz020wbs@163.com

QQ:1564443073

网址:http://www.020wbs.com/

首页 > 二次开发Ecshop二次开发 > ecshop首页生成静态首页插件(修复可使用)

二次开发Ecshop二次开发

二次开发Ecshop二次开发

ecshop首页生成静态首页插件(修复可使用)

注:网上流传的生成静态并不能正确工作,生成后会提示本“本商城尚未开启WAP功能”。这个在这里已经修复,注意红色的地方。生成静态HTML的原理很简单,就是模拟浏览器访问页面,得到html源码,然后输出保存为HTML文件
=======
如果网站访问量比较大,我们可以把ecshop的网站的首页生成html,减小服务器的压力,让ecshop首页打开得更快一点,后台设置效果如图:
实现这个可以按以下两步完成(另外主机这边则应该把index.html的优先访问级别排在index.php前面):
一、打开admin/templates/top.htm
<div id="send_info" style="padding: 5px 10px 0 0; clear:right;text-align: right; color: #FF9900;width:40%;float: right;">
{if $send_mail_on eq 'on'}
<span id="send_msg"><img src="images/top_loader.gif" width="16" height="16" alt="{$lang.loading}" style="vertical-align: middle" /> {$lang.email_sending}</span>
<a href="javascript:;" id="lnkSwitch" style="margin-right:10px;color: #FF9900;text-decoration: underline">{$lang.pause}</a>
{/if}
<a href="index.php?act=clear_cache" target="main-frame" class="fix-submenu">{$lang.clear_cache}</a>
<a href="privilege.php?act=logout" target="_top" class="fix-submenu">{$lang.signout}</a>
</div>
修改成
<div id="send_info" style="padding: 5px 10px 0 0; clear:right;text-align: right; color: #FF9900;width:40%;float: right;">
{if $send_mail_on eq 'on'}
<span id="send_msg"><img src="images/top_loader.gif" width="16" height="16" alt="{$lang.loading}" style="vertical-align: middle" /> {$lang.email_sending}</span>
<a href="javascript:;" id="lnkSwitch" style="margin-right:10px;color: #FF9900;text-decoration: underline">{$lang.pause}</a>
{/if}
<a href="../_creat_index.php" target="main-frame" class="fix-submenu">生成静态首页</a>
<a href="index.php?act=clear_cache" target="main-frame" class="fix-submenu">{$lang.clear_cache}</a>
<a href="privilege.php?act=logout" target="_top" class="fix-submenu">{$lang.signout}</a>
</div>
增加生成静态页的后台操作链接
二、前台增加生成html的php文件_creat_index.php

<?php
define('IN_ECS', true);
define('INIT_NO_USERS', true);
define('INIT_NO_SMARTY', true);
require(dirname(__FILE__) . '/includes/init.php');
$site_url = rtrim($ecs->url(),'/');
$index_file = ROOT_PATH . 'index.html';
$source_url = $site_url . '/index.php';
ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; GreenBrowser)');
file_put_contents($index_file, file_get_contents($source_url), LOCK_EX);
?>
静态首页已经生成<a href="<?php echo $site_url; ?>" target="_blank">浏览首页…</a>