dede中调用文章属性的名称(调用自定义属性名称)
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>接下来我们给大家分享一下如何在文章页内调用相关的属性名称:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<img style="max-width:100%!important;height:auto!important;"title="dede中调用文章属性的名称(调用自定义属性名称)" alt="dede中调用文章属性的名称(调用自定义属性名称)" src="https://zhuji.jb51.net/uploads/img/202305/171f86c99f9fd74c453ea9c9d9dbde94.jpg"></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
我们可以看到,这个标题后面就是我们需要的属性名字,通过代码分析我们可以看到调用的代码为</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
<pre class="brush:xhtml;">
{dede:field.flag function='IsCommendArchives(@me)'/}</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
我们能够看出来,这个调用需要函数:IsCommendArchives(@me)</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
这个函数就是把文章内获取的flag的内容,转化对应的名字。函数内容为:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
<pre class="brush:php;toolbar:false;">
function IsCommendArchives($iscommend)
{
global $arcatts;
$sn = '';
foreach($arcatts as $k=>$v)
{
$v = cn_substr($v, 2);
$sn .= (preg_match("#".$k."#", $iscommend) ? ','.$v : '');
}
$sn = trim($sn);
if($sn=='') return '';
else return "$sn";
}</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
其中$k就是属性名称,我们可以选择用","隔开,也支持HTML书写,更加灵活大家在其他地方调用</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
在给大家一个示例:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<img style="max-width:100%!important;height:auto!important;"title="dede中调用文章属性的名称(调用自定义属性名称)" alt="dede中调用文章属性的名称(调用自定义属性名称)" src="https://zhuji.jb51.net/uploads/img/202305/2cabd2969b118be47ebbbaa4d5382eb0.jpg"></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
大家有没有受到启发,发散思维吧</p>
頁:
[1]