首页 > 教程 > 前端技术 > 模板制作

    收藏

    DESTOON 增加内容页的浏览历史记录
    DT模板2016-09-15模板制作69℃
    广告
    核心提示:一:简介最近在用destoon弄一个商城模板,考虑到商城都有浏览历史记录,而destoon却没有 无语,所以自己动手弄了一个 要实现的功能:1、要显示的浏览记录数量。2、最近浏览的内容排在最前面。3、保存记录的时间。4、调用一个文件适用与多个栏目。5、清除浏览历史记录。6、伪静态的地址也能用。二:源代码div id=history?php
    一:简介
    最近在用destoon弄一个商城模板,考虑到商城都有浏览历史记录,而destoon却没有 无语,所以自己动手弄了一个 要实现的功能:
    1、要显示的浏览记录数量。
    2、最近浏览的内容排在最前面。
    3、保存记录的时间。
    4、调用一个文件适用与多个栏目。
    5、清除浏览历史记录。
    6、伪静态的地址也能用。
    二:源代码
    <div id="history">
    <?php
    $MOD_name = "$MOD[moduledir]";
    if (!empty($_cookie["$MOD_name"]['history'])){
    $history = explode(',', $_cookie["$MOD_name"]['history']);
    array_unshift($history, $itemid);
    $history = array_unique($history);
    while (count($history) > 5){
    array_pop($history);
    }setcookie("$MOD_name".'[history]', implode(',', $history), time() + 86400 * 7,'/'."$MOD_name","$DT_PATH");
    } else {
    setcookie("$MOD_name".'[history]', $itemid, time() + 86400 * 7,'/'."$MOD_name","$DT_PATH");
    } $history =isset ($_cookie["$MOD_name"]['history']) ? $_cookie["$MOD_name"]['history'] : 0;
    if($del=="del"){
    setcookie("$MOD_name".'[history]', "", time()-3600);
    echo header("Location: $linkurl");
    };
    $query = mysql_query("SELECt * FROM `$table` WHERe `itemid` in ($history) ORDER BY FIELD(itemid,$history)");
    while($t = mysql_fetch_array($query)){?>
    {if $module == 'group'}
    <div class="browse_box">
    <div class="browse_img" style="height:105px;">
    <a href="{$t [linkurl]}" target="_blank">
    <img src="{$t ['thumb']}" width="158" height="105" title="{$t[title]}" alt="{$t [alt]}" style="display: inline;height:105px;"></a>
    </div>
    <div class="browse_name">
    <a href="{$t [linkurl]}" target="_blank">{$t[title]}</a>
    </div>
    <div class="browse_price"> <b class="green">价格:¥</b> <b class="orange">{$t[price]}</b>
    </div>
    </div>
    {elseif $module == 'mall'}
    <div class="browse_box">
    <div class="browse_img">
    <a href="{$t[linkurl]}" target="_blank">
    <img src="{str_replace('.thumb.', '.middle.', $t ['thumb'])}" width="158" height="126" title="{$t[title]}" alt="{$t [alt]}" style="display: inline;"></a>
    </div>
    <div class="browse_name">
    <a href="{$t [linkurl]}" target="_blank">{$t[title]}</a>
    </div>
    <div class="browse_price"> <b class="green">价格:¥</b> <b class="orange">{$t[price]}</b>
    </div>
    </div>
    {elseif $module == 'sell'}
    <ul><li><a href="{$t [linkurl]}" target="_blank">{$t[title]}</a></li></ul>
    {elseif $module == 'buy'}
    <ul><li><a href="{$t [linkurl]}" target="_blank">{$t[title]}</a></li></ul>
    {/if}
    <?php } ?>
    </div>
    不喜欢以上写的格式可以这样写
    {if $history}
    <div class="history">
    <div class="history_title f_l">
    <span class="f_r"><a href='{$MOD[linkurl]}show.php?itemid={$itemid}&delete=delete'>清空记录</a></span>
    <h3 class="f_l">浏览记录</h3>
    </div>
    <ul>
    {php $xxid=explode(',',$history)}
    {loop $xxid $t}
    <!--{php $tags=tag("moduleid=$moduleid&showcat=1&condition=status=3 and itemid=$t&template=null");}-->
    {loop $tags $i $t}
    <li>
    <a href="{$t [linkurl]}" target="_blank"><img src ="{imgurl ($t[thumb], 1)}"javascript:this.src='{DT _SKIN}images/nopic.gif';" alt="{$t [alt]}" width="120" height="90" ><p>{$t[title]}</p></a>
    </li>
    {/loop}
    {/loop}
    </ul>
    </div>
    {/if}
 
  • 文本链接:https://mbtxw.com/Course/show.php?itemid=39
  • 文章来源:模板模板
  • 版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。
0相关评论