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

2,582 人次阅读
没有评论

共计 2106 个字符,预计需要花费 6 分钟才能阅读完成。

网上流传的生成静态并不能正确工作,生成后会提示本“本商城尚未开启WAP功能”。这个在这里已经修复,注意红色的地方。生成静态HTML的原理很简单,就是模拟浏览器访问页面,得到html源码,然后输出保存为HTML文件
=======
如果网站访问量比较大,我们可以把ecshop的网站的首页生成html,减小服务器的压力,让ecshop首页打开得更快一点,后台设置效果如图:
实现这个可以按以下两步完成(另外主机这边则应该把index.html的优先访问级别排在index.php前面):
一、打开admin/templates/top.htm
[php]
<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>
[/php]
修改成
[php]
<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>
[/php]
增加生成静态页的后台操作链接
二、前台增加生成html的php文件_creat_index.php
[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>
[/php]

正文完
 0