江左布衣 發表於 2024-4-28 00:00:00

详解织梦模板DEDECMS核心类TypeLink.class.php功能分析

<p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="">
        DedeCMS 核心类TypeLink.class.php摘要笔记,学习php就是借鉴与分析,让自己的掌握的更多。</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="">
        注:&#39;//+&#39; 表示为本人另外加上的注释</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=""><pre class="brush:php;toolbar:false;">Class&nbsp;TypeLink&nbsp;
{&nbsp;
var&nbsp;$typeDir;&nbsp;
var&nbsp;$dsql;&nbsp;
var&nbsp;$TypeID;&nbsp;//+&nbsp;类别ID&nbsp;
var&nbsp;$baseDir;&nbsp;//+&nbsp;站点根网址&nbsp;
var&nbsp;$modDir;&nbsp;//+&nbsp;模板目录&nbsp;
var&nbsp;$indexUrl;&nbsp;//+&nbsp;主页链接地址&nbsp;
var&nbsp;$indexName;&nbsp;//+&nbsp;主页链接名&nbsp;
var&nbsp;$TypeInfos;&nbsp;//+&nbsp;类目信息&nbsp;
var&nbsp;$SplitSymbol;&nbsp;//+&nbsp;栏目位置的间隔符号&nbsp;
var&nbsp;$valuePosition;&nbsp;//+&nbsp;主页&nbsp;&gt;&nbsp;国内&nbsp;&gt;&nbsp;两会动态&nbsp;&gt;&nbsp;(带连接)&nbsp;
var&nbsp;$valuePositionName;&nbsp;//+&nbsp;主页&nbsp;&gt;&nbsp;国内&nbsp;&gt;&nbsp;两会动态&nbsp;&gt;&nbsp;(不带连接)&nbsp;
var&nbsp;$OptionArrayList;&nbsp;//+&nbsp;类目下拉列表</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft=""><strong>功能一,获得某类目的链接</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="">
        代码如下:</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=""><pre class="brush:php;toolbar:false;">//获得某分类连接的URL&nbsp;&nbsp;
function&nbsp;GetOneTypeUrl($typeinfos)&nbsp;&nbsp;
{&nbsp;&nbsp;
return&nbsp;GetTypeUrl();&nbsp;&nbsp;
}&nbsp;&nbsp;
//获得某个类目的超链接信息&nbsp;&nbsp;
function&nbsp;GetOneTypeLink($typeinfos)&nbsp;&nbsp;
{&nbsp;&nbsp;
$typepage&nbsp;=&nbsp;$this-&gt;GetOneTypeUrl($typeinfos);&nbsp;&nbsp;
$typelink&nbsp;=&nbsp;&quot;&quot;.$typeinfos[&#39;typename&#39;].&quot;&quot;;&nbsp;&nbsp;
return&nbsp;$typelink;&nbsp;&nbsp;
}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft=""><strong>功能二,获得某类目的链接列表 如:&#39;类目一&gt;类目二&gt;&#39; 这样的形式。</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="">
        代码如下:</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=""><pre class="brush:php;toolbar:false;">//islink&nbsp;表示返回的列表是否带连接&nbsp;&nbsp;
//+&nbsp;SplitSymbol&nbsp;栏目位置的间隔符号&nbsp;dede系统默认为&#39;-&#39;&nbsp;&nbsp;
function&nbsp;GetPositionLink($islink=true)&nbsp;&nbsp;
{&nbsp;//+&nbsp;获得&nbsp;主页链接名&nbsp;&nbsp;
$indexpage&nbsp;=&nbsp;&quot;indexUrl.&quot;&quot;&nbsp;_href=&quot;&quot;.$this-&gt;indexUrl.&quot;&quot;&gt;&quot;.$this-&gt;indexName.&quot;&quot;;&nbsp;&nbsp;
……&nbsp;&nbsp;
……&nbsp;&nbsp;
else&nbsp;&nbsp;
{&nbsp;&nbsp;
if($islink)&nbsp;&nbsp;
{&nbsp;&nbsp;
$this-&gt;valuePosition&nbsp;=&nbsp;$this-&gt;GetOneTypeLink($this-&gt;TypeInfos);&nbsp;&nbsp;
if($this-&gt;TypeInfos[&#39;reid&#39;]!=0)&nbsp;&nbsp;
{&nbsp;&nbsp;
//调用递归逻辑&nbsp;&nbsp;
$this-&gt;LogicGetPosition($this-&gt;TypeInfos[&#39;reid&#39;],true);&nbsp;&nbsp;
}&nbsp;&nbsp;
$this-&gt;valuePosition&nbsp;=&nbsp;$indexpage.$this-&gt;SplitSymbol.$this-&gt;valuePosition;&nbsp;&nbsp;
return&nbsp;$this-&gt;valuePosition.$this-&gt;SplitSymbol;&nbsp;&nbsp;
}&nbsp;&nbsp;
else&nbsp;&nbsp;
{&nbsp;&nbsp;
$this-&gt;valuePositionName&nbsp;=&nbsp;$this-&gt;TypeInfos[&#39;typename&#39;];&nbsp;&nbsp;
if($this-&gt;TypeInfos[&#39;reid&#39;]!=0)&nbsp;&nbsp;
{&nbsp;&nbsp;
//调用递归逻辑&nbsp;&nbsp;
$this-&gt;LogicGetPosition($this-&gt;TypeInfos[&#39;reid&#39;],false);&nbsp;&nbsp;
}&nbsp;&nbsp;
return&nbsp;$this-&gt;valuePositionName;&nbsp;&nbsp;
}&nbsp;&nbsp;
}&nbsp;&nbsp;
}&nbsp;&nbsp;
//获得某类目的链接列表,递归逻辑部分&nbsp;&nbsp;
function&nbsp;LogicGetPosition($id,$islink)&nbsp;&nbsp;
{&nbsp;&nbsp;
$this-&gt;dsql-&gt;SetQuery(&quot;&nbsp;SQL查询语句&nbsp;&quot;);&nbsp;&nbsp;
$tinfos&nbsp;=&nbsp;$this-&gt;dsql-&gt;GetOne();&nbsp;&nbsp;
if($islink)&nbsp;&nbsp;
{&nbsp;//+&nbsp;列表带连接&nbsp;&nbsp;
$this-&gt;valuePosition&nbsp;=&nbsp;$this-&gt;GetOneTypeLink($tinfos).$this-&gt;SplitSymbol.$this-&gt;valuePosition;&nbsp;&nbsp;
}&nbsp;&nbsp;
else&nbsp;&nbsp;
{&nbsp;//+&nbsp;列表不带连接&nbsp;&nbsp;
$this-&gt;valuePositionName&nbsp;=&nbsp;$tinfos[&#39;typename&#39;].$this-&gt;SplitSymbol.$this-&gt;valuePositionName;&nbsp;&nbsp;
}&nbsp;&nbsp;
if($tinfos[&#39;reid&#39;]&gt;0)&nbsp;&nbsp;
{&nbsp;//+&nbsp;递归&nbsp;&nbsp;
$this-&gt;LogicGetPosition($tinfos[&#39;reid&#39;],$islink);&nbsp;&nbsp;
}&nbsp;&nbsp;
}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft=""><strong>功能三, 获得类别列表 高级搜索功能 即highsearch.php 即要用到此函数</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="">
        代码如下:</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=""><pre class="brush:php;toolbar:false;">//hid&nbsp;是指默认选中类目,0&nbsp;表示&quot;请选择类目&quot;或&quot;不限类目&quot;&nbsp;&nbsp;
//oper&nbsp;是用户允许管理的类目,0&nbsp;表示所有类目&nbsp;&nbsp;
//channeltype&nbsp;是指类目的内容类型,0&nbsp;表示不限频道&nbsp;&nbsp;
function&nbsp;GetOptionArray($hid=0,$oper=0,$channeltype=0,$usersg=0)&nbsp;&nbsp;
{&nbsp;&nbsp;
return&nbsp;$this-&gt;GetOptionList($hid,$oper,$channeltype,$usersg);&nbsp;&nbsp;
}&nbsp;&nbsp;
function&nbsp;GetOptionList($hid=0,$oper=0,$channeltype=0,$usersg=0)&nbsp;&nbsp;
{&nbsp;&nbsp;
return&nbsp;$this-&gt;OptionArrayList;&nbsp;&nbsp;
}&nbsp;&nbsp;
//+&nbsp;为下级类目递归加上&nbsp;&#39;-&#39;&nbsp;&nbsp;
function&nbsp;LogicGetOptionArray($id,&nbsp;$step,&nbsp;$oper=0)&nbsp;&nbsp;
{&nbsp;&nbsp;
}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft=""><strong>功能四,</strong></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=""><pre class="brush:php;toolbar:false;">//获得与该类相关的类目,本函数应用于模板标记{dede:channel}{/dede:channel}中&nbsp;
//$typetype&nbsp;的值为:&nbsp;sun&nbsp;下级分类&nbsp;self&nbsp;同级分类&nbsp;top&nbsp;顶级分类&nbsp;
代码如下:
function&nbsp;GetChannelList($typeid=0,$reid=0,$row=8,$typetype=&#39;sun&#39;,$innertext=&#39;&#39;,&nbsp;&nbsp;
$col=1,$tablewidth=100,$myinnertext=&#39;&#39;)&nbsp;&nbsp;
{&nbsp;&nbsp;
}&nbsp;&nbsp;
}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="">
        以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</p>
頁: [1]
查看完整版本: 详解织梦模板DEDECMS核心类TypeLink.class.php功能分析