DedeCMS调取当前文档地址、当前栏目URL地址
dedecms
dedecms二次开发:自定义模型使用教程
DedeCMS内容页调用当前栏目其实用下来是调用不出来的,{dede:field.typename/}是有效的,可是 {dede:field.typeurl/}却调不出文档当前栏目所在目录链接URL。查了下网上有网友提供了解决的办法,贴出来大家分享:
方法一:
dedecms
<span class="sh_cbracket"><span style="font-size:12px;">{</span></span><span style="font-size:12px;">dede</span><span class="sh_symbol"><span style="font-size:12px;">:</span></span><span style="font-size:12px;">type typeid</span><span class="sh_symbol"><span style="font-size:12px;">=</span></span><span class="sh_string" style="color: rgb(255, 0, 255);"><span style="font-size:12px;">'0prime; row=1}[field:typelink /]{/dede:type}</span></span>
方法二:
动手改装一下函数了,利用DEDECMS自定义函数的接口文件,我们在文章页中的标记把
<span class="sh_cbracket"><span style="font-size:12px;">{</span></span><span style="font-size:12px;">dede</span><span class="sh_symbol"><span style="font-size:12px;">:</span></span><span style="font-size:12px;">field</span><span class="sh_symbol"><span style="font-size:12px;">.</span></span><span style="font-size:12px;">typeid </span><span class="sh_keyword" style="color: rgb(165, 42, 42);"><span style="font-size:12px;">function</span></span><span class="sh_symbol"><span style="font-size:12px;">=</span></span><span class="sh_string" style="color: rgb(255, 0, 255);"><span style="font-size:12px;">'typeurl_arc(@me)'</span></span><span class="sh_symbol"><span style="font-size:12px;">/</span></span><span class="sh_cbracket"><span style="font-size:12px;">}</span></span>
这个放在内容页的模板中,把如下函数:
<span class="sh_keyword" style="color: rgb(165, 42, 42);"><span style="font-size:12px;">function</span></span> <span class="sh_function" style="font-weight: bold;"><span style="font-size:12px;">typeurl_arc</span></span><span class="sh_symbol"><span style="font-size:12px;">(</span></span><span style="font-size:12px;">$typeid</span><span class="sh_symbol"><span style="font-size:12px;">)</span></span><span class="sh_cbracket"><span style="font-size:12px;">{</span></span><br><span style="font-size:12px;">$typeurl </span><span class="sh_symbol"><span style="font-size:12px;">=</span></span> <span class="sh_string" style="color: rgb(255, 0, 255);"><span style="font-size:12px;">";</span></span><br><span class="sh_string" style="color: rgb(255, 0, 255);"><span style="font-size:12px;">$dsql = new DedeSql(false);</span></span><br><span class="sh_string" style="color: rgb(255, 0, 255);"><span style="font-size:12px;">$row = $dsql ->GetOne("</span></span><span style="font-size:12px;">select typedir from dede_arctype where id</span><span class="sh_symbol"><span style="font-size:12px;">=</span></span><span style="font-size:12px;">$typeid</span><span class="sh_string" style="color: rgb(255, 0, 255);"><span style="font-size:12px;">");</span></span><br><span class="sh_string" style="color: rgb(255, 0, 255);"><span style="font-size:12px;">$typeurl = MfTypedir($row['typedir']);</span></span><br><span class="sh_string" style="color: rgb(255, 0, 255);"><span style="font-size:12px;">return $typeurl;</span></span><br><span class="sh_string" style="color: rgb(255, 0, 255);"><span style="font-size:12px;">} </span></span>
放到include/extend.func.php文档里,注:MfTypedir为dedecms系统内置函数。
补充:dedecms获取当前文档url地址的方法:
<span class="sh_cbracket"><span style="font-size:12px;">{</span></span><span style="font-size:12px;">dede</span><span class="sh_symbol"><span style="font-size:12px;">:</span></span><span style="font-size:12px;">field name</span><span class="sh_symbol"><span style="font-size:12px;">=</span></span><span class="sh_string" style="color: rgb(255, 0, 255);"><span style="font-size:12px;">'arcurl'</span></span><span class="sh_symbol"><span style="font-size:12px;">/</span></span><span class="sh_cbracket"><span style="font-size:12px;">}</span></span>
dedecms二次开发:自定义模型使用教程