您现在的位置是:首页 > cms教程 > ecshop商城教程ecshop商城教程
ecshop调用很新文章在任何页面显示或者随机文章
夜蓉2024-01-16 19:47:45ecshop商城教程已有13人查阅
导读ECSHOP在任何页面调用很新文章或者随机文章步:一、让很新文章变成随机文章打开根目录下 index.php 文件查找:' ORDER BY a.arti
ECSHOP在任何页面调用很新文章或者随机文章
步骤一:
一、让很新文章变成随机文章
打开根目录下 index.php 文件
查找: 修改为: 第二步:
将以下代码保存为 new_articles_ec.lbi 文件
<?php $GLOBALS['smarty']->assign(‘new_articles’, index_get_new_articles()); function index_get_new_articles() { $sql = ‘SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type, ac.cat_id, ac.cat_name ‘ . ‘ FROM ‘ . $GLOBALS['ecs']->table(‘article’) . ‘ AS a, ‘ . $GLOBALS['ecs']->table(‘article_cat’) . ‘ AS ac’ . ‘ WHERE a.is_open = 1 AND a.cat_id = ac.cat_id AND ac.cat_type = 1′ . ‘ ORDER BY a.article_type DESC, a.add_time DESC LIMIT ‘ . $GLOBALS['_CFG']['article_number']; $res = $GLOBALS['db']->getAll($sql); $arr = array(); foreach ($res AS $idx => $row) { $arr[$idx]['id'] = $row['article_id']; $arr[$idx]['title'] = $row['title']; $arr[$idx]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ? sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title']; $arr[$idx]['cat_name'] = $row['cat_name']; $arr[$idx]['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']); $arr[$idx]['url'] = $row['open_type'] != 1 ? build_uri(‘article’, array(‘aid’ => $row['article_id']), $row['title']) : trim($row['file_url']); $arr[$idx]['cat_url'] = build_uri(‘article_cat’, array(‘acid’ => $row['cat_id']), $row['cat_name']); } return $arr; } ?> <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″> <div> <h2>很新文章</h2> <div> <!- {if $new_articles} -> <!- {foreach name=new_articles from=$new_articles item=article} -> <!- {if $smarty.foreach.new_articles.index lt 8} 限制文章显示数量 -> <a href=”{$article.url}” title=”{$article.title|escape:html}”>{$article.short_title|truncate:30}</a><br /> <!- {/if} -> <!-{/foreach}-> <!-{else}-> 当前没有很新文章! <!- {/if} -> </div> </div>
再把这个文件上传到模板文件的 library 目录下。
再在你需要显视文章的位置加入以下代码
<!- #BeginLibraryItem “/library/new_articles_ec.lbi” -><!- #EndLibraryItem ->
如果你修改了 步,那显视的是随机文章,如果没有修改,那就是很新文章。
步骤一:
一、让很新文章变成随机文章
打开根目录下 index.php 文件
查找: 修改为: 第二步:
将以下代码保存为 new_articles_ec.lbi 文件
<?php $GLOBALS['smarty']->assign(‘new_articles’, index_get_new_articles()); function index_get_new_articles() { $sql = ‘SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type, ac.cat_id, ac.cat_name ‘ . ‘ FROM ‘ . $GLOBALS['ecs']->table(‘article’) . ‘ AS a, ‘ . $GLOBALS['ecs']->table(‘article_cat’) . ‘ AS ac’ . ‘ WHERE a.is_open = 1 AND a.cat_id = ac.cat_id AND ac.cat_type = 1′ . ‘ ORDER BY a.article_type DESC, a.add_time DESC LIMIT ‘ . $GLOBALS['_CFG']['article_number']; $res = $GLOBALS['db']->getAll($sql); $arr = array(); foreach ($res AS $idx => $row) { $arr[$idx]['id'] = $row['article_id']; $arr[$idx]['title'] = $row['title']; $arr[$idx]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ? sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title']; $arr[$idx]['cat_name'] = $row['cat_name']; $arr[$idx]['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']); $arr[$idx]['url'] = $row['open_type'] != 1 ? build_uri(‘article’, array(‘aid’ => $row['article_id']), $row['title']) : trim($row['file_url']); $arr[$idx]['cat_url'] = build_uri(‘article_cat’, array(‘acid’ => $row['cat_id']), $row['cat_name']); } return $arr; } ?> <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″> <div> <h2>很新文章</h2> <div> <!- {if $new_articles} -> <!- {foreach name=new_articles from=$new_articles item=article} -> <!- {if $smarty.foreach.new_articles.index lt 8} 限制文章显示数量 -> <a href=”{$article.url}” title=”{$article.title|escape:html}”>{$article.short_title|truncate:30}</a><br /> <!- {/if} -> <!-{/foreach}-> <!-{else}-> 当前没有很新文章! <!- {/if} -> </div> </div>
再把这个文件上传到模板文件的 library 目录下。
再在你需要显视文章的位置加入以下代码
<!- #BeginLibraryItem “/library/new_articles_ec.lbi” -><!- #EndLibraryItem ->
如果你修改了 步,那显视的是随机文章,如果没有修改,那就是很新文章。
本文标签:
很赞哦! (0)
暂无内容 |
暂无内容 |
相关文章
暂无内容 |
暂无内容 |
随机图文
ecshop移动端支付宝支付接口对接实例
初始页,提交基本信息到api页面,进入API页,获取表单数据和配置数据,发起移动支付请求,上面是配置内容,支付后,调整到处理页面ecshop文章列表页面里怎么添加内容摘要的方法
本教程中讲到的“内容摘要”指的是文章内容的前 60个字符(当然也可以是前40个,前50个等等)下面以 官方默认模板 为例进行讲解:ecshop后台0day漏洞原理和利用方法
可以看到如果$filename以”str:”开头那么就调用_eval()函数执行”str:”后面的代码,不过在执行之前系统调用fetch_str函数进行字符查找和替换。ecshop添加独立商品评论页面可分页显示
ECSHOP添加独立商品评论页面可分页显示通过以下方法可以实现ecshop使用一个单独立的页面来显示所有的评论,并在评论中显示会员 评论的商品 评论内容等。
留言与评论 (共有 0 条评论) |