如何让ecshop网店系统文章内容随机显示

如题所述

先修改后台:
找到ecshop的添加文档,admin/article.php文件。找到288行
if ($exc->edit("title='$_POST[title]', cat_id='$_POST[article_cat]', article_type='$_POST

[article_type]', is_open='$_POST[is_open]', author='$_POST[author]', author_email='$_POST

[author_email]', keywords ='$_POST[keywords]', file_url ='$file_url', open_type='$open_type',

content='$_POST[FCKeditor1]', link='$_POST[link_url]', description = '$_POST[description]'", $_POST

['id']))
修改成
$add_time = gmtime();
if ($exc->edit("title='$_POST[title]', add_time='$add_time',cat_id='$_POST[article_cat]',

article_type='$_POST[article_type]', is_open='$_POST[is_open]', author='$_POST[author]',

author_email='$_POST[author_email]', keywords ='$_POST[keywords]', file_url ='$file_url',

open_type='$open_type', content='$_POST[FCKeditor1]', link='$_POST[link_url]', description = '$_POST

[description]'", $_POST['id']))
再找到includes/lib_article.php找到48与56行把' ORDER BY article_type DESC, article_id DESC';修改成' ORDER BY article_type DESC, add_time DESC';

根据更新时间进行排序并不是我所需要的,但却给了我一个非常重要的提示。非常简单的修改串代码让ecshop文章实现随机展示找到includes/lib_article.php找到48与56行把' ORDER BY article_type DESC, article_id DESC';
修改成
' ORDER BY rand()';
注意是两处!就这么简单就完成,每次更新缓存,文章的排序就会改变一次。
温馨提示:答案为网友推荐,仅供参考
相似回答