原文来自:https://www.zixuephp.com
dedecms 实现织梦搜索页面调用 文章功能
直接进入主题,今天使用dedecms织梦开源系统做企业网站,要实现在搜索页面里调用推荐新闻的,但是dedecms织梦在搜索页面里不可以直接使用以下代码调用文章的:
- {dede:arclistflag='c'titlelen=42row=6}
- [field:title/]
- [field:descriptionfunction='cn_substr(@me,80)'/]…
- {/dede:arclist}
如是笔者硬是把搜索页面的内核代码完全的看了一遍,终于实现了搜索页面调用“推荐文章”.
为什么搜索页面不能调用新闻呢,下面我来告诉大家,找到arc.searchview.class.php文件,看以下代码:
- functionDisplay()
- {
- foreach($this->dtp->CTagsas$tagid=>$ctag)
- {
- $tagname=$ctag->GetName();
- if($tagname=="list")
- {
- $limitstart=($this->PageNo-1)*$this->PageSize;
- $row=$this->PageSize;
- if(trim($ctag->GetInnerText())=="")
- {
- $InnerText=GetSysTemplets("list_fulllist.htm");
- }
- else
- {
- $InnerText=trim($ctag->GetInnerText());
- }
- $this->dtp->Assign($tagid,
- $this->GetArcList($limitstart,
- $row,
- $ctag->GetAtt("col"),
- $ctag->GetAtt("titlelen"),
- $ctag->GetAtt("infolen"),
- $ctag->GetAtt("imgwidth"),
- $ctag->GetAtt("imgheight"),
- $this->ChannelType,
- $this->OrderBy,
- $InnerText,
- $ctag->GetAtt("tablewidth"))
- );
- }
- elseif($tagname=="pagelist")
- {
- $list_len=trim($ctag->GetAtt("listsize"));
- if($list_len=="")
- {
- $list_len=3;
- }
- $this->dtp->Assign($tagid,$this->GetPageListDM($list_len));
- }
- elseif($tagname=="likewords")
- {
- $this->dtp->Assign($tagid,$this->GetLikeWords($ctag->GetAtt('num')));
- }
- elseif($tagname=="hotwords")
- {
- $this->dtp->Assign($tagid,lib_hotwords($ctag,$this));
- }
- elseif($tagname=="field")
- {
- //类别的指定字段
- if(isset($this->Fields[$ctag->GetAtt('name')]))
- {
- $this->dtp->Assign($tagid,$this->Fields[$ctag->GetAtt('name')]);
- }
- else
- {
- $this->dtp->Assign($tagid,"");
- }
- }
- elseif($tagname=="channel")
- {
- //下级频道列表
- if($this->TypeID>0)
- {
- $typeid=$this->TypeID;$reid=$this->TypeLink->TypeInfos['reid'];
- }
- else
- {
- $typeid=0;$reid=0;
- }
- $GLOBALS['envs']['typeid']=$typeid;
- $GLOBALS['envs']['reid']=$typeid;
- $this->dtp->Assign($tagid,lib_channel($ctag,$this));
- }//Endif
- elseif($tagname=="arclist")//这是笔者自己加的代码只要加上这行代码我们就能调用“acrlist”标签
- {
- MakeOneTag($this->dtp,$this);
- }
- }
- global$keyword,$oldkeyword;
- if(!emptyempty($oldkeyword))$keyword=$oldkeyword;
- $this->dtp->Display();
- }
只要把代码中加注释的那段语句加入arc.searchview.class.php文件里就可以实现搜索页面调用文章.