dedecms中调用ecshop产品

功能需求:在dedecms中调用ecshop系统中的产品

dedecms v5.7 + ecshop v2.7.2

/include/taglib/ecsonegood.lib.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
 * ecshop 单个产品调用
 *
 */
 
function lib_ecsonegood(&$ctag,&$refObj)
{
    global $dsql,$cfg_basehost;
    $attlist="limit|1";
    FillAttsDefault($ctag->CAttribute->Items,$attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $revalue = '';  
 
    $sql = "SELECT * FROM `ecs_goods` ORDER BY rand( ) LIMIT " . $limit;
    $dsql->SetQuery($sql);
    $dsql->Execute();
    while($dbrow=$dsql->GetObject())
    {
        $url = $cfg_basehost.'/goods-'.$dbrow->goods_id.'.html';
        $img = $cfg_basehost.'/'.$dbrow->goods_thumb;
        $alt = cn_substr($dbrow->goods_name,$titlelen);
 
        $revalue .= '<a href="'.$url.'" target="_blank"><img src="'.$img.'"
 
alt="'.$alt.'"></a>';
    }
    return $revalue;
 
}

模版标签如下:
{dede:ecsonegood /}

转载自:http://hi.baidu.com/heui/blog/item/75d9429034f40a95a877a48d.html

posted on 2011-06-06 03:18  heui  阅读(508)  评论(0编辑  收藏  举报