zoukankan      html  css  js  c++  java
  • dede织梦产品中心点击产品分类不跳转新页面,实现对应产品及分页的方法

    点击产品分类不跳新页面,即不刷新,实现如下:

    js:

    $(".show-product").eq(0).show();//不同产品分类的共同class
    var lis = $(".product ul li");//左侧产品分类
    var k;
    for(var i = 0; i < lis.length; i++) {
    lis[i].index = i;
    $(".product ul li").hover(function() {
    $(".product ul li").css({
    "background": "#fff",
    });
    $(".product ul li a").css({
    "color": "#333",
    });
    $(".product ul li a.thisclass").css({
    "color": "#fff",
    });
    $(this).css({
    "background": "#046355",
    });
    $(this).find("a").css({
    "color": "#fff",
    });

    k = this.index;
    k = parseInt(k + 1);
    $(".show-product").hide();
    $(".show-product").eq(k).show();
    })
    }

    用arclist标签+Ajax实现织梦首页分页

    1、必须在首页<head></head>中引入

    <script language="javascript" type="text/javascript" src="{dede:global.cfg_cmsurl/}/include/dedeajax2.js"></script>

    2、<head></head>必须加入

    <script>
    function multi(pagenum, tagid) {
    var taget_obj = document.getElementById(tagid);
    var taget_obj_page = document.getElementById("page_" + tagid);
    myajax = new DedeAjax(taget_obj, false, false, '', '', '');
    myajax.SendGet2("/plus/arcmulti.php?mtype=0&pnum=" + pagenum + '&tagid=' + tagid);
    myajax = new DedeAjax(taget_obj_page, false, false, '', '', '');
    myajax.SendGet2("/plus/arcmulti.php?mtype=1&pnum=" + pagenum + '&tagid=' + tagid);
    DedeXHTTP = null;
    }
    </script>

    3、在arclist标签中必须含有tagid与pagesize参数。 第一个是缓存名,第二个是单页条数。

    {dede:arclist tagid='index' pagesize='20'}

          <li><a href="[field:arcurl/]" >[field:title/]</a></li>

          <p>[field:info/]...</p>

    {/dede:arclist}

    4、必须存在arcpagelist标签,且必须声明缓存参数tagid且缓存参数与arclist中tagid保持一致

    {dede:arcpagelist tagid='index'/}

    此时只显示页码,没有 首页、上一页、下一页、尾页等,添加如下:

    找到文件dedeinclude aglibarcpagelist.lib.php 
    找到方法function multipage 翻页样式在这里修改 
    以下是做好的一断代码可以直接复制:

    function multipage($allItemTotal, $currPageNum, $pageSize, $tagid='')
    {
    if ($allItemTotal == 0) return "";

    //计算总页数
    $pagesNum = ceil($allItemTotal/$pageSize);

    //第一页显示
    $firstPage = ($currPageNum <= 1) ? "<span>[首页]</span>" : "<a href='javascript:multi(1,"{$tagid}")' title='第1页'><span>[首页]</span></a>";

    //最后一页显示
    $lastPage = ($currPageNum >= $pagesNum)? "<span>[尾页]</span>". $currPageNum : "<a href='javascript:multi(". $pagesNum . ","{$tagid}")' title='第". $pagesNum ."页'><span>[尾页]</span></a>";

    //上一页显示
    $prePage = ($currPageNum <= 1) ? "<span>[上一页]</span>" : "<a href='javascript:multi(". ($currPageNum-1) . ","{$tagid}")' accesskey='p' title='上一页'><span>[上一页]</span></a>";

    //下一页显示
    $nextPage = ($currPageNum >= $pagesNum) ? "<span>[下一页]</span>" : "<a href='javascript:multi(". ($currPageNum+1) .","{$tagid}")' title='下一页'><span>[下一页]</span></a>";

    //共X页 共X条记录
    $pagesNum2 = "&nbsp;&nbsp;共&nbsp;".$pagesNum."&nbsp;页&nbsp;&nbsp;共&nbsp;".$allItemTotal."&nbsp;条记录";

    //按页显示
    $listNums = "";
    $listNums.= $firstPage;
    $listNums.= $prePage;
    for ($i=($currPageNum-4); $i<($currPageNum+9); $i++) {
    if ($i < 1 || $i > $pagesNum) continue;
    if ($i == $currPageNum)
    {
    $listNums.= "<a href='javascript:void(0)' class='thislink'><span>".$i."</span></a>";
    }else
    {
    $listNums.= " <a href='javascript:multi(". $i .","{$tagid}")' title='". $i ."'><span>". $i ."</span></a> ";
    }
    }
    $listNums.= $nextPage;
    $listNums.= $lastPage;
    $listNums.= $pagesNum2;

    $returnUrl = $listNums;
    return $returnUrl;
    }

    刷新后效果:[首页][上一页]12345[下一页][尾页]


    原文链接:https://blog.csdn.net/qq_41104911/java/article/details/81510589

    例如:

    <div class="leftbar">
    <div class="leftMenu product">

    左侧产品分类

    <h3>{dede:field.typeid runphp='yes'}$ID = @me; $sql = "SELECT * FROM `dede_arctype` WHERE id=$ID";$query = mysql_query($sql);$row=mysql_fetch_array($query); $relID = "$row[reid]"; if($relID == 0) {@me = $row[typename];}else{$sql = "SELECT `typename` FROM `dede_arctype` WHERE id=$relID";$query = mysql_query($sql);$row=mysql_fetch_array($query); @me = $row[typename];}{/dede:field.typeid}</h3>
    <ul class="submenu" id="subnav">
    {dede:channel type='son' currentstyle="
    <li>
    <a href='javascript::' class='thisclass'>~typename~</a>
    </li>
    "}
    <li>
    <a href='javascript::'>[field:typename/]</a>
    </li>
    {/dede:channel}
    </ul>
    </div>
    </div>

    右侧产品及分页

    <div class="rightSide">
    <div class="title">
    <h3><a href='{dede:field name='typeurl'/}'>{dede:field name='typename'/}</a></h3>
    <ul class="bread">
    <li>当前位置:</li>
    <li>{dede:field name='position'/}</li>
    </ul>
    </div>


    <div class="show_content padding-large-bottom">

    //产品分类--typeid:分类id

    //产品分类1

    <div class="show-product">
    <div class="line-big"> {dede:arclist typeid='20' tagid='p1' pagesize='9' titlelen='50' orderby='pubdate'}
    <div class="pro-item">
    <div class="media-img">
    <a href="[field:arcurl/]" title="[field:title/]"><img src="[field:picname/]" alt="[field:title/]" /></a>
    </div>
    <h3 class="text-center"><a href="[field:arcurl/]" title="[field:title/]">[field:title/]</a></h3>
    </div>
    {/dede:arclist}
    </div>
    {dede:arcpagelist tagid='p1'/}
    </div>

    //产品分类2

    <div class="show-product">
    <div class="line-big"> {dede:arclist typeid='19' tagid='p2' pagesize='9' titlelen='50' orderby='pubdate'}
    <div class="pro-item">
    <div class="media-img">
    <a href="[field:arcurl/]" title="[field:title/]"><img src="[field:picname/]" alt="[field:title/]" /></a>
    </div>
    <h3 class="text-center"><a href="[field:arcurl/]" title="[field:title/]">[field:title/]</a></h3>
    </div>
    {/dede:arclist}
    </div>
    {dede:arcpagelist tagid='p2'/}
    </div>

    </div>
    </div>

    如遇问题,参考:

    http://blog.sina.com.cn/s/blog_5409afc00101h7hz.html

  • 相关阅读:
    java自学
    java自学
    java自学
    java自学
    Interesting Finds: 2009 11.17 ~ 11.22
    Interesting Finds: 2009 10.09 ~10.13
    Interesting Finds: 2009 10.01 ~ 10.08
    Interesting Finds: 2009 10.14 ~ 10.21
    Interesting Finds: 2009 11.01 ~ 11.08
    Interesting Finds: 2009 10.25 ~ 10.31
  • 原文地址:https://www.cnblogs.com/zyl-930826/p/13029373.html
Copyright © 2011-2022 走看看