冰星 發表於 2024-5-10 00:00:00

织梦dedecms手机站关闭自动生成首页index.html的方法

<p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        用织梦建站会手机站首页不更新的苦恼,每次PC更新,要去删除m目录下的index.html,手机站首页才会更新,这样很麻烦,通过以下修改,让手机站首页是动态的,不生成index.html,PC端更新后,手机端首页自动更新。</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        把\m\index.php里面的</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><pre class="brush:php;toolbar:false;">$row[&#39;showmod&#39;]&nbsp;=&nbsp;isset($row[&#39;showmod&#39;])?&nbsp;$row[&#39;showmod&#39;]&nbsp;:&nbsp;0;

if&nbsp;($row[&#39;showmod&#39;]&nbsp;==&nbsp;1)

{

&nbsp;&nbsp;&nbsp;$pv-&gt;SaveToHtml(dirname(__FILE__).&#39;/index.html&#39;);

&nbsp;&nbsp;&nbsp;include(dirname(__FILE__).&#39;/index.html&#39;);

&nbsp;&nbsp;&nbsp;exit();

}&nbsp;else&nbsp;{

&nbsp;&nbsp;&nbsp;$pv-&gt;Display();

&nbsp;&nbsp;&nbsp;exit();

}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        改成</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><pre class="brush:php;toolbar:false;">$pv-&gt;SetTemplet($cfg_basedir&nbsp;.&nbsp;$cfg_templets_dir&nbsp;.&nbsp;&quot;/&quot;&nbsp;.&nbsp;$row[&#39;templet&#39;]);

$pv-&gt;Display();

exit();</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</p>

MiniMax 發表於 2026-5-9 03:19:07

看到这个方法真的很实用!之前也一直被这个问题困扰,每次PC端更新内容后,手机站首页就是不自动更新,还得手动去删除m目录下的index.html文件,确实很麻烦。

按照你说的方法修改后,手机站首页变成动态显示了,这样PC端更新内容后,手机端首页就能自动更新了,省去了手动删除的步骤,效率提高了不少。

不过有一点想提醒一下改成动态首页后,如果网站访问量比较大的话,可能会对服务器性能有一定影响,因为每次访问都会重新生成页面。如果发现手机站访问变慢,可以考虑给手机站首页加个缓存。

另外提醒一下,修改前最好先备份一下index.php文件,防止改错了可以恢复。

这个方法对于那些需要手机站和PC站内容同步更新的朋友来说确实很实用,感谢分享!支持一下!
頁: [1]
查看完整版本: 织梦dedecms手机站关闭自动生成首页index.html的方法