search
HomeBackend DevelopmentPHP TutorialDedeCMS 核心类TypeLink.class.php摘要笔记_PHP

dede

注:'//+' 表示为本人另外加上的注释
Class TypeLink
{
var $typeDir;
var $dsql;
var $TypeID; //+ 类别ID
var $baseDir; //+ 站点根网址
var $modDir; //+ 模板目录
var $indexUrl; //+ 主页链接地址
var $indexName; //+ 主页链接名
var $TypeInfos; //+ 类目信息
var $SplitSymbol; //+ 栏目位置的间隔符号
var $valuePosition; //+ 主页 > 国内 > 两会动态 > (带连接)
var $valuePositionName; //+ 主页 > 国内 > 两会动态 > (不带连接)
var $OptionArrayList; //+ 类目下拉列表
功能一,获得某类目的链接
复制代码 代码如下:
//获得某分类连接的URL
function GetOneTypeUrl($typeinfos)
{
return GetTypeUrl();
}
//获得某个类目的超链接信息
function GetOneTypeLink($typeinfos)
{
$typepage = $this->GetOneTypeUrl($typeinfos);
$typelink = "".$typeinfos['typename']."";
return $typelink;
}

功能二,获得某类目的链接列表 如:'类目一>类目二>' 这样的形式。
复制代码 代码如下:
//islink 表示返回的列表是否带连接
//+ SplitSymbol 栏目位置的间隔符号 dede系统默认为'-'
function GetPositionLink($islink=true)
{ //+ 获得 主页链接名
$indexpage = "".$this->indexName."";
……
……
else
{
if($islink)
{
$this->valuePosition = $this->GetOneTypeLink($this->TypeInfos);
if($this->TypeInfos['reid']!=0)
{
//调用递归逻辑
$this->LogicGetPosition($this->TypeInfos['reid'],true);
}
$this->valuePosition = $indexpage.$this->SplitSymbol.$this->valuePosition;
return $this->valuePosition.$this->SplitSymbol;
}
else
{
$this->valuePositionName = $this->TypeInfos['typename'];
if($this->TypeInfos['reid']!=0)
{
//调用递归逻辑
$this->LogicGetPosition($this->TypeInfos['reid'],false);
}
return $this->valuePositionName;
}
}
}
//获得某类目的链接列表,递归逻辑部分
function LogicGetPosition($id,$islink)
{
$this->dsql->SetQuery(" SQL查询语句 ");
$tinfos = $this->dsql->GetOne();
if($islink)
{ //+ 列表带连接
$this->valuePosition = $this->GetOneTypeLink($tinfos).$this->SplitSymbol.$this->valuePosition;
}
else
{ //+ 列表不带连接
$this->valuePositionName = $tinfos['typename'].$this->SplitSymbol.$this->valuePositionName;
}
if($tinfos['reid']>0)
{ //+ 递归
$this->LogicGetPosition($tinfos['reid'],$islink);
}
}

功能三, 获得类别列表 高级搜索功能 即highsearch.php 即要用到此函数
复制代码 代码如下:
//hid 是指默认选中类目,0 表示“请选择类目”或“不限类目”
//oper 是用户允许管理的类目,0 表示所有类目
//channeltype 是指类目的内容类型,0 表示不限频道
function GetOptionArray($hid=0,$oper=0,$channeltype=0,$usersg=0)
{
return $this->GetOptionList($hid,$oper,$channeltype,$usersg);
}
function GetOptionList($hid=0,$oper=0,$channeltype=0,$usersg=0)
{
return $this->OptionArrayList;
}
//+ 为下级类目递归加上 '-'
function LogicGetOptionArray($id, $step, $oper=0)
{
}

功能四,
//获得与该类相关的类目,本函数应用于模板标记{dede:channel}{/dede:channel}中
//$typetype 的值为: sun 下级分类 self 同级分类 top 顶级分类
复制代码 代码如下:
function GetChannelList($typeid=0,$reid=0,$row=8,$typetype='sun',$innertext='',
$col=1,$tablewidth=100,$myinnertext='')
{
}
}
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP Performance Tuning for High Traffic WebsitesPHP Performance Tuning for High Traffic WebsitesMay 14, 2025 am 12:13 AM

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

Dependency Injection in PHP: Code Examples for BeginnersDependency Injection in PHP: Code Examples for BeginnersMay 14, 2025 am 12:08 AM

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

PHP Performance: is it possible to optimize the application?PHP Performance: is it possible to optimize the application?May 14, 2025 am 12:04 AM

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

PHP Performance Optimization: The Ultimate GuidePHP Performance Optimization: The Ultimate GuideMay 14, 2025 am 12:02 AM

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor