玄龙CMS sql标签调用任意表数据
xuanlong sql调用任意表数据
/* * 参数说明: * sql 构造的select语句 * @empty sql查询错误或者没有数据时候输出 暂无数据 */
温馨提示:
若调用的文章列表,则必须关联两个表,作为生成文章地址规则所用 1、#@__article表字段包含[id、flag、senddate、filename、ishtml、redirecturl] 2、#@__category表字段包含[urlrule] 3、若包含用户自定义字段、图集需要关联内容表 当前模型标识符_content
{xuanlong:sql sql="select a.id,a.title,a.flag,a.senddate,a.filename,b.urlrule,a.ishtml,a.litpic,a.click,b.typename,b.typedir,c.imgs from #@__article a inner join #@__category b on a.categoryid=b.id inner join #@__article_content c on a.id=c.aid order by a.id asc limit 0,3" @empty='[[<div style="color:red">暂无数据</div>]]'} [field:id/] //id<br> [field:title/] //标题<br> [field:title function="html2text(@me)"/] //调用系统自带函数对标题进行过滤处理<br> [field:arcurl/] //文章地址<br> [field:typename/] //文章所属栏目<br> [field:typedir/] //文章所属栏目地址<br> [field:test/] //用户自定义字段 前提是查询出来<br> <a href="[field:arcurl/]">[field:title function="html2text(@me)"/]</a> //调用自定义函数html2text<br> -------------------------------------------------------------------<br> 一、sql语句中嵌套if elseif 判断 {{xuanlong:if [field:litpic/]!=''}}//判断文章缩略图不为空时输出 <img src="[field:litpic/]"/> {{xuanlong:elseif [field:click/]>=35}} //当前文章点击次数大于35 [field:click/] {{xuanlong:else}} 6666 {{/xuanlong:if}} ----------------------------------------------------------------------<br> 二、sql语句中调用图集 {xuanlong:custom='imgs' limit="0,3" @empty="[[777]]"} //调用图集0至3张图 imgs为图集字段名 <img alt="[field:img_txt/]" src="[field:img_src/]"/> //[field:img_txt/] 固定字段,图集图片说明 / [field:img_src/]固定字段,图片地址 {{xuanlong:if [field:litpic/]!=''}}//判断文章缩略图不为空时输出 <img src="[field:litpic/]"/> {{xuanlong:elseif [field:click/]>=35}} //当前文章点击次数大于35 [field:click/] {{xuanlong:else}} 6666 {{/xuanlong:if}} {/xuanlong:custom} {/xuanlong:sql}