商品详情页在指定的标签下面显示关联文章内容

2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家



给商品详情页面上的“商品描述”“商品属性”那个位置又增加了一个标签,想让这个标签点开以后,显示关联文章的内容

我在goods.dwt中的相应位置添加了如下代码:
<blockquote>
<div class="boxCenterList_car">
<!-- {foreach from=$goods_article_list item=article} -->
<a href="{$article.url}" title="{$article.title|escape:html}">{$article.short_title|escape:html}</a><br />
<!--{/foreach}-->
</blockquote>

显示的只是文章标题,不知道如何写显示文章内容的代码,哪位高人,帮助提供个参考,多谢了!

回答:
<blockquote>
<div class="boxCenterList_car">
<!-- {foreach from=$goods_article_list item=article} -->
<a href="{$article.url}" title="{$article.title|escape:html}">{$article.short_title|escape:html}</a><br />{$article.content|escape:html}
<!--{/foreach}-->
</blockquote>




good.php文件找到
/**
* 获得指定商品的关联文章
*
* @accesspublic
* @paraminteger$goods_id
* @returnvoid
*/
function get_linked_articles($goods_id)
{
$sql = 'SELECT a.article_id, a.title, a.file_url, a.open_type, a.add_time , a.content ' .
'FROM ' . $GLOBALS['ecs']->table('goods_article') . ' AS g, ' .
$GLOBALS['ecs']->table('article') . ' AS a ' .
"WHERE g.article_id = a.article_id AND g.goods_id = '$goods_id' AND a.is_open = 1 " .
'ORDER BY a.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;
}


红色代码

注意红色代码...

一语道破,问题解决,非常之感谢!



我按2楼的办法在good.php文件加好后商品详情页面打不开,有如下报错信息,请帮看看怎么回事吧!


MySQL server error report:Array ( [0] => Array ( [message] => MySQL Query Error ) [1] => Array ( [sql] => SELECT a.article_id, a.title, a.file_url, a.open_type, a.add_time , a.contentFROM `slecshop`.`slecs_goods_article` AS g, `slecshop`.`slecs_article` AS a WHERE g.article_id = a.article_id AND g.goods_id = '81' AND a.is_open = 1 ORDER BY a.add_time DESC ) [2] => Array ( [error] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.`slecs_goods_article` AS g, `slecshop`.`slecs_article` AS a WHERE g.article_id ' at line 1 ) [3] => Array ( [errno] => 1064 ) )



另外,这个代码加goods.dwt中具体哪个位置?

<blockquote>
<div class="boxCenterList_car">
<!-- {foreach from=$goods_article_list item=article} -->
<a href="{$article.url}" title="{$article.title|escape:html}">{$article.short_title|escape:html}</a><br />{$article.content|escape:html}
<!--{/foreach}-->
</blockquote>