AspCms在子菜单栏目后面显示产品数量或新闻数量的解决办法

15 年 1 月 11 日 星期日 (已编辑)
379 字
2 分钟

有时候我们需要在产品栏目后面显示出该栏目下有多少产品,或者新闻栏目下有多少条新闻。例如子页面导航为产品总分类(18)产品分类一(10)产品分类二(3)产品分类三(5)数字代表该栏目下有多少产品。以下内容是模拟显示产品数量的解决办法。

此文仅提供解决思路,如果使用以下代码有问题,还需自行修改。

打开inc/AspCms_MainClass.asp在479行左右找到

| 1 2 3 4 5 6 7 8 9 10 11 | for each matchfield in matchesfield fieldNameAndAttr=regExpReplace(matchfield.SubMatches(0),"[\s]+",chr(32)) fieldNameAndAttr=trimOuter(fieldNameAndAttr) m=instr(fieldNameAndAttr,chr(32)) if m > 0 then fieldName=left(fieldNameAndAttr,m - 1) fieldAttr = right(fieldNameAndAttr,len(fieldNameAndAttr) - m) elsefieldName=fieldNameAndAttr fieldAttr = ""end if | | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

在下面加入

| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | dim selsortid,contotal,contype,newstotal,prototal,downtotal,pictotal,total selsortid=linkArray(3,i) set contype=conn.Exec("select sortType from {prefix}Sort where sortID="&selsortid,"r1") set contotal=conn.Exec("select count (*) from {prefix}Content where sortID="&selsortid,"r1") if contype(0)=1 or contype(0)=7 then alertMsgAndGo contype(0),"-1"elseset total=conn.Exec("select count (*) from {prefix}Content as c,{prefix}Sort as s where c.sortID="&selsortid&" and c.sortid=s.sortid and s.sortType="&contype(0),"r1") end ifif contype(0)=2 then newstotal=total(0) elseif contype(0)=3 then prototal=total(0) elseif contype(0)=4 then downtotal=total(0) elseif contype(0)=6 then pictotal=total(0) end if | | -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

然后在select case fieldName里面加入

| 1 2 3 4 5 6 7 8 9 10 | case "total"loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,contotal(0)) case "newstotal"loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,newstotal) case "prototal"loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,prototal) case "downtotal"loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,downtotal) case "pictotal"loopstrLinklistNew=replaceStr(loopstrLinklistNew,matchfield.value,pictotal) | | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

前台调用代码在各页面的栏目循环中加入:新闻:[navlist

] 产品:[navlist
] 下载:[navlist
] 图片:[navlist
] 不区分分类[navlist
]

通过 AspCms在子菜单栏目后面显示产品数量或新闻数量的解决办法 _乐知心觉_新浪博客.

欢迎关注我的其它发布渠道
公众号小程序

文章标题:AspCms在子菜单栏目后面显示产品数量或新闻数量的解决办法

文章作者:bmqy

文章链接:https://www.bmqy.net/1518.html[复制]

最后修改时间:


商业转载请联系站长获得授权,非商业转载请注明本文出处及文章链接,您可以自由地在任何媒体以任何形式复制和分发作品,也可以修改和创作,但是分发衍生作品时必须采用相同的许可协议。
本文采用CC BY-NC-SA 4.0进行许可。