Récemment, parce que la société a besoin de commencer à faire ECShop, la page d'accueil a besoin d'appeler une certaine partie des produits, donc je pense à l'appel par mots clés, ne dites pas beaucoup, directement sur le code :
1. Ajoutez ceci dans /includes/lib_goods.php :
fonction get_keyword_goods($keyword = ")
{
$time = gmtime () ;
$order_type = $GLOBALS['_CFG']['recommand_order'] ;
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, www.example.com _price, www.example.com _price AS org_price, g.promote_price, '.
« IFNULL (mp.user_price, www.example.com _price * '$_SESSION[discount]') AS _ price shop, ».
« Promote _ start _ date, promote _ end _ date, g.goods _ brief, g.goods _ thumb, goods _ img, b.brand _ name, ».
« www.example.com _best, g.is_new, g.is_hot, g.is_promote, RAND () AS rnd ».
« De ». $GLOBALS['ecs']->table('goods').« Comme g ».
« Joindre à gauche »$GLOBALS['ecs']->table('brand'). ' AS b ON b.brand_id = g.brand_id'.
"Left Join" $GLOBALS['ecs'] ->table('member_price').« Comme MP. »
« ON mp.goods_id = g.goods_id ET mp.user_rank = ' $_SESSION[user_rank] ' ».
« WHERE www.example.com _ on_sale = 1 ET g.is_alone_sale = 1 ET g.is_delete = 0 ».
» et g.keywords comme ' %$keyword %' » ;
$sql.= $order_type = 0 ?« ORDER BY g.sort _ order, g.last _ update DESC » : « ORDER BY rnd » ;
$result = $GLOBALS['db'] ->getAll($sql) ;
$goods = array() ;
foreach ($resultat AS $idx = > $row)
{
si ($row ['promote_price'] > 0)
{
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']) ;
$goods[$idx]['promote _ price'] = $promote _ price > 0 ? prix _ format ($promote _ price) : » ;
}
Autre
{
$goods[$idx]['promote_price'] = " ;
}
$goods[$idx]['id'] = $row['goods_id'] ;
$goods[$idx]['nom'] = $row['goods_name'] ;
$goods[$idx] ['brief'] = $row['goods_brief'] ;
$goods[$idx]['brand_name'] = $row['brand_name'] ;
$goods[$idx]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']) ;
$goods[$idx]['short _ name'] = $GLOBALS['_ CFG']['goods_name_length'] > 0 ? sub _ str($row['nom des marchandises'], $GLOBALS['_CFG']['nom des marchandises']) : $row['nom des marchandises'] ;
$goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'],$row['goods_name_style']) ;
$goods[$idx]['market_price'] = price_format($row['market_price']) ;
$goods[$idx]['shop _ price'] = price_format($row['shop_price']) ;
$goods[$idx] ['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true) ;
$goods[$idx] ['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']) ;
$goods[$idx] ['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name'] ;
}
Retour de $goods.
}
2.Écrivez ceci avant assign _ dynamic ('index') ; dans le fichier php de la page (généralement index.php) qui doit être invoquée pour le produit.
$smarty-> assign('keyword_1', get_keyword_goods ("États-Unis") ;
Parmi eux, la page d'accueil du centre commercial est le mot-clé que j'ai rempli dans la colonne "Autres informations" - "Mots clés de marchandises" pour l'appel
3. Utilisez foreach dans dwt ou lbi qui nécessite une commodité pour appeler.
<! - {foreach from=$keyword_1 item=goods} ->
<! - {/foreach} - >