aspcms首页content内容html代码过滤,ASP-ASPCMS功能增强之{aspcms:cimages}标签怎么从图片组中去除过滤文章缩略图...

ASPcms在文章管理时可以上传设置“文章缩略图”,还能上传图片,细心的小朋友肯定可以看出来,这些图片是保存在一起的!

如果你有分析数据库的话那么你会发现图片组保存在一个字段里,而文章缩略图也保存在另外一个字段里,并且文章缩略图的值还在图片组的字段里面有一个记录。

也就是我们在ASPcms系统里面如果调用{aspcms:cimages}标签的话,显示出来的图片组里面包含文章缩略图!问题在于文章缩略图我们大部分情况下是不需要显示的,怎么办?

DIY解决吧~

打开inc\AspCms_templateFun.asp文件查找如下代码

Function makeContentImages(sContent)

在查找到的位置下方增加下面的变量定义

dim exc_IndexImage,img_index

往下找下面的代码:

m_maxcount = parseArr(match.SubMatches(0))(“count”)

增加下面的代码

exc_IndexImage = parseArr(match.SubMatches(0))(“indeximage”)

这个代码的含义就是我们前台模板调用的时候需要增加一个参数,参数名字就叫做indeximage。

PS:前台的调用代码{aspcms:cimages count=5 contentid=1 indeximage=true}……{/aspcms:cimages}

接着再找到

sql = “select imagepath from {prefix}Content where ContentID=” & m_contentid

我们把这段代码做一下修改:

sql = “select imagepath,IndexImage from {prefix}Content where ContentID=” & m_contentid

就是在读写参数时将缩略图的字段也一起读出来,用于下面程序的比对。

继续往下找

img=rs(0)

然后在这个代码下面增加

img_index = rs(1)

再往下找:

for each img in imgs

if iCount < cint(m_maxcount) then

将这个if逻辑判断修改一下,这个if判断就是我们要处理的地方噢。

if iCount < cint(m_maxcount) then

if exc_IndexImage=”true” and img=img_index then

iCount = iCount – 1

else

soutput = soutput & match.SubMatches(1)

soutput =  replace(soutput,”[cimages:src]”,img)

soutput = replace(soutput,”[cimages:i]”,iCount+1)

end if

end if

然后,保存,更新,你就会发现{aspcms:cimages}标签多了一个参数了噢,具体使用方法如下:

{aspcms:cimages count=5 contentid=1 indeximage=true}

[cimages:src]

[cimages:i]

{/aspcms:cimages}

附录:makeContentImages完整的代码

'2013.03.20 增加一个参数IndexImage,如果为true则输出的图片列表中不包含缩略图文件

Function makeContentImages(sContent)

'{aspcms:cimages count=5 contentid=1}

'[cimages:src]

'{/aspcms:cimages}

'if instr(sConetnt,"{aspcms:cimages") then

dim rs,sql,img,imgs

dim m_labelRule,m_labelRuleField

dim regExpObj

dim match,matches

dim m_contentid

dim m_maxcount,iCount

dim soutput

soutput = ""

m_contentid = empty

iCount = 0

sql = "select * from {prefix}Content where contentid="

'set rs = conn.exec(sql,"r1")

set regExpObj= new RegExp

m_labelRule="{aspcms:cimages([\s\S]*?)}([\s\S]*?){/aspcms:cimages}"

dim exc_IndexImage,img_index

regExpObj.Pattern=m_labelRule

set matches=regExpObj.Execute(sContent)

for each match in matches

m_contentid = parseArr(match.SubMatches(0))("contentid")

m_maxcount = parseArr(match.SubMatches(0))("count")

exc_IndexImage = parseArr(match.SubMatches(0))("indeximage")

if isnul(exc_IndexImage) then exc_IndexImage=false

if isnul(m_maxcount) or not isnumeric(m_maxcount) then m_maxcount = 9999

if not isnul(m_contentid) then

if not isnumeric(m_contentid) then m_contentid=-1

'2013.03.20 增加获取缩略图字段,用于对参数的控制处理

sql = "select imagepath,IndexImage from {prefix}Content where ContentID=" & m_contentid

set rs = conn.exec(sql,"r1")

if not rs.eof then

img=rs(0)

img_index = rs(1)  '2013.03.20

end if

rs.close

set rs = nothing

imgs = split(img,"|")

for each img in imgs

if iCount < cint(m_maxcount) then

if exc_IndexImage="true" and img=img_index then

iCount = iCount - 1

else

soutput = soutput & match.SubMatches(1)

'soutput = replace(soutput,"[aspcms:cimagesitem]","")

'soutput = replace(soutput,"[/aspcms:cimagesitem]","")

soutput =  replace(soutput,"[cimages:src]",img)

soutput = replace(soutput,"[cimages:i]",iCount+1)

end if

'echo img & "
"

end if

iCount = iCount + 1

next

end if

'die soutput

sContent=replaceStr(sContent,match.value,soutput)

'die sConetnt

next

if instr(sContent,"{aspcms:cimages") > 0 then

'die "停止"

makeContentImages sContent

end if

'end if

makeContentImages = sContent

End Function

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ASPCMS是由上谷网络开发的全新内核的开源企业建站系统,能够胜任企业多种建站需求,并且支持模版自定义、支持扩展插件等等,能够在短时间内完成企业建站。 本版为直接使用版 , 下载后上传即可使用 , 详细请查看下载源码中文档说明。 功能列表: 1、支持一键生成html 2、支持google和百度地图生成 3、RSS生成 4、URL自定义 5、增加按指定日期生成内容 6、自定义生成目录、文件名称 7、分类自定义模板、内容自定义模板 8、分类访问权限控制 9、一键切换模板 10、模板防盗功能 11、在线修改模板,CSS文件 12、采集功能 13、招聘应聘功能 14、TAG功能 15、批量添加分类功能 16、水印功能 17、留言,评论内容过滤功能 18、在线升级功能 19、事件邮件提醒功能 20、增加相册功能 21、自定义标签功能 22、广告位管理功能 23、浮动广告,对联广告,右下弹出广告 24、支持无限极分类; 25、支持自定义标题、自定义关键词、自定义描述 26、支持栏目,分类是否启用开关 27、支持外部跳转链接控制 28、拥有留言板、友情链接,上传文件管理,数据库备份/恢复,在线客服,幻灯片等常用功能 29、特有冗余文件检测功能,可以检测无用的上传文件并删除 ASPCMS开源企业网站管理系统 更新日志: v2.6.2 2016年7月20日 1.开启无限多语言支持,在后台"多语言设置"中添加 2.增加前台多语言切换(使用a链接"/?lg=cn/en") 3.修复多语言时单篇文章未按语言显示 4.清理后台部分无效外部链接文件加快载入速度 5.清理默认模板部分后门文件 6.修改后台手机版开关默认关闭 7.更新手机号码匹配正则函数,支持最新号码段 8.修复留言板手机号码不能正常检测 9.增加栏目调用数量控制参数num,如{aspcms:navlist num=5} 10.增加栏目下面内容数量调用标签[navlist:num] 备注: 1.感谢网友"謨葾天"提供宝贵修改意见 2.多语言环境幻灯片调用建议使用ABCD来代表各语言 3.多语言环境友情链接建议使用group分组调用 4.后台上传资料时请在网页右上角先确认当前的语言 5.后台添加语言时一般只需要模板目录不一样就可以 6.对于多语言的更进一步融合,可以用自定义标签替换模板文字,实现共用一套模板 v2.6.1 2016年7月19日 1.修复上一版本CNZZ新添加后不解析标签 2.修复从外部复制统计代码,前台网页无法解析" "字符 3.增加静态模式手机与PC模式互转 4.增加PC访问手机版时的URL跳转 v2.6 2016年7月18日 1.增加手机网页静态生成 2.增加手机网站后台开关 3.完善手机版跳转,实现手机无缝跳转对应页面 4.修复UTF-8模式时后台插件配置界面乱码 5.增加时间标签样式style=m 、style=d用于单独调用月份和日 6.修改后台自定义标签为纯文本调用,并修复图片上传功能 7.去除后台中的无用的提示语并修正部分错误提示 8.去除后台信息泄露文件Company.asp 9.修复使用CNZZ统计时二次保存网站设置后CNZZ前台出现两次 10.修复UTF-8模式时首页错误提示乱码问题 v2.5.9 2016年7月17日 1.修复{aspcms:prevtitle}标签无法解析 2.修改{aspcms:top}对应top.html,添加{aspcms:head}、{aspcms:left}、{aspcms:comm} 3.修复UTF-8模板时生成静态时文件格式 4.修复后台模板格式切换丢失Charset参数值 5.修复后台栏目标签上传代码混乱问题 6.修复前台调用[about:IndexImage][about:pic]之间混乱 7.修复前台{aspcms:indeximage}调用字段 8.修复后台冗余文件清理功能将栏目、文章、幻灯片BCD的正常文件被清理掉

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值