-
-
- $prev_gid = $db->getRow("SELECT goods_id,goods_name FROM " .$ecs->table('goods'). " WHERE cat_id=" . $goods['cat_id'] . " AND goods_id > " . $goods['goods_id'] . " AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0 LIMIT 1");
-
- if (!emptyempty($prev_gid))
-
- {
- $prev_good['goods_name'] = $prev_gid['goods_name'];
-
- $prev_good['url'] = build_uri('goods', array('gid' => $prev_gid['goods_id']),$prev_gid['goods_name']);
-
- $smarty->assign('prev_good', $prev_good);
-
- }
-
- $next_gid = $db->getone("SELECT max(goods_id) FROM " . $ecs->table('goods') . " WHERE cat_id=".$goods['cat_id']." AND goods_id < ".$goods['goods_id'] . " AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0");
-
- if (!emptyempty($next_gid))
-
- {
-
- $next_good['goods_name'] = $db -> getOne("select goods_name from ".$ecs->table('goods')." where goods_id =".$next_gid);
-
- $next_good['url'] = build_uri('goods', array('gid' => $next_gid),$next_good['goods_name']);
-
- $smarty->assign('next_good', $next_good);
- }
2,在goods.dwt模版文件,在适当的位置加上:
- <br><hr color=red>
- {if $prev_good}
- 【上一个礼品】<a href="{$prev_good.url}" title="{$prev_good.goods_name}" >{$prev_good.goods_name}</a>
- {/if}<br>
- {if $next_good}
- 【下一个礼品】<a href="{$next_good.url}" title="{$next_good.goods_name}">{$next_good.goods_name}</a>
- {/if}
3.demo 参见截图
4.作用:方便导航;利于SEO。欢迎大家意见和交流