织梦文档自定义属性调用输出文章跳转网址

栏目:DedeCMS 来源:网络 关注:0 时间:2019-09-18

织梦文档,当你把某个文档的自定义属性设置为跳转[j]时,我们希望能直接在页面中输入这个文档的跳转链接作为a标签里的链接。

dede:arclist标签中调用方法
{dede:arclist typeid='2' row='10' channelid='1' addfields='redirecturl'}
<a href="[field:redirecturl/]">[field:title/]</a>
{/dede:arclist}

channelid='1'里面的1是模型id
织梦文档自定义属性调用输出文章跳转网址
addfields='redirecturl'里面的 redirecturl 其实就是跳转地址字段名,因为这个字段是在附加表
织梦文档自定义属性调用输出文章跳转网址

dede:list标签中调用方法
1、在内容模型-普通文章模型(或者其他模型)-基本设置-列表附加字段,添加:redirecturl
织梦文档自定义属性调用输出文章跳转网址
2、在内容模型-普通文章模型(或者其他模型)-字段管理-模型字段配置(文本模式),添加:
<field:redirecturl itemname="跳转网址" type="text" isnull="true" islist="1" default="" rename="" />
织梦文档自定义属性调用输出文章跳转网址
添加好这2步以后就可以直接在dede:list标签里直接使用[field:redirecturl/]标签来调用跳转地址了
{dede:list pagesize='10' titlelen='250'}
<a href="[field:redirecturl/]">[field:title/]</a>
{/dede:list}

不需要写其他多余的channelid='1'addfields='redirecturl'
如果有的文档不是跳转属性,想要输出正常的文档链接,那把
href="[field:redirecturl/]"
改成:
href="[field:array runphp=yes]@me = (@me['redirecturl'] == '' ? @me['arcurl'] : @me['redirecturl']);[/field:array]"

最终效果:
织梦文档自定义属性调用输出文章跳转网址

本文标题:织梦文档自定义属性调用输出文章跳转网址
本文地址:http://www.q0738.com/dedecms/18621.html