Ecshop obtains related articles of all products under the specified product category
/*** Get the associated articles for all items under the specified category * sun04zh3-20130321 * @ access public * @ Param integer $ cat_id * @ return array */function get_category_linked_articles ($ cat_id) {$ SQL = 'select. article_id,. title,. file_url,. open_type,. add_time '. 'from '. $ globals ['ecs']-> table ('goods _ article '). 'As Ga ,'. $ globals ['ecs']-> table ('Article '). as ,'. $ globals ['ecs']-> table ('goods '). 'As G '. "Where ga. article _ Id =. article_id and ". get_children ($ cat_id ). "and. is_open = 1 and GA. goods_id = G. goods_id ". 'order by. add_time DESC '; $ res = $ globals ['db']-> query ($ SQL); $ arr = array (); while ($ ROW = $ globals ['db']-> fetchrow ($ res) {$ row ['url'] = $ row ['open _ type']! = 1? Build_uri ('Article', array ('aid '=> $ row ['Article _ id']), $ row ['title']): trim ($ row ['file _ url']); $ row ['add _ time'] = local_date ($ globals ['_ CFG'] ['date _ format'], $ row ['add _ time']); $ row ['short _ title'] = $ globals ['_ CFG'] ['Article _ title_length ']> 0? Sub_str ($ row ['title'], $ globals ['_ CFG'] ['Article _ title_length ']): $ row ['title']; $ arr [] = $ row;} return $ arr ;}
Category. DWT template page call:
<!--{foreach from=$article_list_jnc item=jnclist}--> <li><a href="{$jnclist.url}" title="{$jnclist.title}">{$jnclist.title}</a></li> <!--{/foreach}-->
Call the corresponding program page of category. php:
$smarty->assign(‘article_list‘, get_category_linked_articles(8));
Ecshop obtains related articles of all products under the specified product category