织梦调取技巧

来源:互联网 发布:java 图片上传非jsp 编辑:程序博客网 时间:2024/05/29 19:42

一、下的站点关键字{dede:global.cfg_keywords/}

二、下站点描述{dede:global.cfg_description/}

三、头部调取默认default下的今天资源{dede:global.cfg_templets_skin/}

四、底部脚本版权信息{dede:global.cfg_powerby/}、{dede:global.cfg_beian/}

五、调取头部或者底部文件{dede:include filename=”yourfilename.htm”/}

六、相关模板更多内容处理方式:

{dede:type typeid='6'}                  <div class="title">[field:typename /]<a href="[field:typelink /]" class="more">> 更多</a></div>                  {/dede:type}  

七、调取文章列表内容:

{dede:arclist row='7' titlelen='60' orderby='pubdate' typeid="6"}                      <li><a href="[field:arcurl/]">[field:title/]</a><div class="date">[field:pubdate function="MyDate('m-d',@me)"/]</div></li>                      {/dede:arclist}  

八、关于我们顶级菜单的内容,直接sql:

{dede:sql sql='Select content,substring(content,1,300) as content from dede_arctype where id=8'}                  <div class="con">                      [field:content function='html2text(@me)'/]                          </div>                  {/dede:sql}  

九、摘要的文章截取,查看更多,缩略图,description:

{dede:arclist row='3' orderby='pubdate' typeid="2"}                  <li>                      <a href="[field:arcurl/]" title="[field:title/]">[field:image/]</a>                      <div class="t"><a href="[field:arcurl/]" title="[field:title/]">[field:title/]</a></div>                      <div class="c">                        [field:description function="cn_substr(@me,268)"/]...<a href="[field:arcurl/]">[查看全文]</a>                      </div>                  </li>                    {/dede:arclist}   

十、日期,

[field:pubdate function="MyDate('m-d',@me)"/] 月日,([field:pubdate function='strftime("%m-%d",@me)'/])==(5-15)([field:pubdate function='strftime("%b %d, %Y",@me)'/])==(May 15, 2008)列表页:[field:pubdate function="GetDateTimeMK(@me)"/]==2008-1-1 18:30:02[field:pubdate function="GetDateMK(@me)"/]==2008-05-15内容页:{dede:field name=’pubdate’ function=’GetDateMk(@me)’/}==2008-05-15{dede:field name=’pubdate’ function=’strftime(“%b %d, %Y”,@me)’/}==May 15, 2008

十一、当前位置:{dede:field name=’position’/}

十二、分页{dede:pagelist listitem=”info,index,end,pre,next,pageno,option” listsize=”5”/}

十三、当前高亮菜单下取顶级菜单

{dede:sql sql='Select content from dede_arctype where id=7'}                       [field:content/]                      {/dede:sql}  

十四、调取一般内容:

<h1>{dede:field.title/}</h1>                  <div class="publish">发布者: {dede:field.writer/}   发布时间: {dede:field.pubdate function="MyDate('Y-m-d H:i',@me)"/}</div>                  <div class="detail">                      {dede:field.body/}                  </div>  

十五、调关键字:

A:调网站关键字:{dede:global.cfg_keywords/}  B、调某个文章的关键字:{dede:field.keywords/}  

十六、调tag标签:基本语法:

{dede:tag sort='new' getall='0'}      <a href='[field:link/]'>[field:tag /]</a>      {/dede:tag}  5.7版本调tag:[field:id function=GetTags(@me)/],修改文件include/extend.func.php,加上自定义函数function get_tags($tag){      $str = str_replace(",", "</span><span>", $tag);      return "<span>".$str."</span>";  }  调用:[field:keywords function="get_tags(@me)"/]  

十七、调指定文章内容:

{dede:arclist idlist='5' limit='0,7' }                          <p class="area-title">[field:title/]</p>                          <p>联系人:[field:description/]</p>                          <p>[field:body/]</p>                          {/dede:arclist}  

十八、调自定义标签:

这里演示在文章中添加一个自定义标签,点击——字段管理——添加新字段——填写提示文字——字段名——保存即可。回到模型管理中基本设置——找到列表附加字段——将刚刚设置的字段名以逗号隔开添加保存即可。
之后打开文章:

调用标签:{dede:field.你的字段名/} 栏目中用:[field.你的字段名/]即可

十九、使用栏目seo标题或者关键字([field:seotitle/] 、[field:keywords/])调不出来?

方法修改php文件。目录include/tablib/channel.lib.php文件第80行。
添加字段名:

seotitle  {          $sql = "SELECT id,typename,seotitle,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath            From `#@__arctype` WHERE reid=0 And ishidden<>1 order by sortrank asc limit 0, $line ";      }      else if($type=='son')      {          if($typeid==0) return '';          $sql = "SELECT id,typename,seotitle,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath            From `#@__arctype` WHERE reid='$typeid' And ishidden<>1 order by sortrank asc limit 0, $line ";      }      else if($type=='self')      {          if($reid==0) return '';          $sql = "SELECT id,typename,seotitle,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath              FROM `#@__arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";      }  其他字段同理!!

二十、织梦调二级栏目:一般用channel处理。

{dede:channel type='son' currentstyle="                  <a href='~typelink~' class='hover'>~typename~</a>                  "}                  <a href='[field:typeurl/]'>[field:typename/]</a>                  {/dede:channel}  首页调:{dede:channelartlist typeid='4'}  <li><a href='{dede:field name='typeurl'/}'>{dede:field name='typename'/}</a></li>  {/dede:channelartlist}  或者:{dede:channelartlist typeid='3,3'}  <a href="{dede:field name='typeurl'/}">{dede:field name='typename'/}</a>  <hr><!-- 这里我们加一个横线,已区分顶级栏目、子栏目,此处为注释文字,可以删除-->  {dede:channel type='son' noself='yes'}  <a href="[field:typelink/]">[field:typename/]</a><br />  {/dede:channel}  {/dede:channelartlist}   特殊处理,需求每个二级分类的样式或者图片不同,需求不同调取,这时我的方法的是用type调用,但是type默认情况下不支持调取描述、关键词等字段,需要到includ/taglib/tag.lib.php中字段管理进行添加字段。{dede:type typeid='38'}                                  <div class="images-single object">                                      <div class="thumb">                                          <a class="img-post" href="[field:typelink/]">                                              <img src="[field:global.cfg_templets_skin/]/images/images/services/1.jpg" alt="image">                                          </a>                                      </div><!-- /.thumb-->                                      <div class="desc-img">                                          <h4 class="title">[field:typename/]</h4>                                      </div><!-- /.desc-img -->                                  </div><!-- /.images-single -->                                  {/dede:type} 

以上代码中链接记得就不是[field:arcurl/]了,而是[field:typelink/],否则会报没有权限修改错误。。

二十一、去除官方版权信息,一个在后台——系统——系统基本设置——网站版本信息去除,再调

{dede:global.cfg_powerby/}  {dede:global.cfg_beian/}  发现还是有,,别急,,去根目录——include——dedesql.class.php——第588-592行注释掉就好了!$arrs1 = array(0x63,0x66,0x67,0x5f,0x70,0x6f,0x77,0x65,0x72,0x62,0x79);  $arrs2 = array(0x20,0x3c,0x61,0x20,0x68,0x72,0x65,0x66,0x3d,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,  0x77,0x77,0x77,0x2e,0x64,0x65,0x64,0x65,0x63,0x6d,0x73,0x2e,0x63,0x6f,0x6d,0x20,0x74,0x61,0x72,  0x67,0x65,0x74,0x3d,0x27,0x5f,0x62,0x6c,0x61,0x6e,0x6b,0x27,0x3e,0x50,0x6f,0x77,0x65,0x72,0x20,  0x62,0x79,0x20,0x44,0x65,0x64,0x65,0x43,0x6d,0x73,0x3c,0x2f,0x61,0x3e);  

二十二、调栏目下指定某一篇文章(idlist):

{dede:arclist row='1' titlelen='24' orderby='pubdate' typeid='25' idlist='6'}                                              <a href="[field:arcurl/]">                                                  <div class="contents-box02-info">                                                      [field:image/]                                                      <h2>                                                          [field:title/]                                                      </h2>                                                      <div class="main-board-info">                                                          <p class="main-board-contents">                                                              [field:shorttitle/]                                             </p>                                                          </div>                                                      </div>                                                  </a>                                              {/dede:arclist}  

二十三、调指定栏目的内容、标题、url地址:

直接sql查询:{dede:sql sql='Select description from dede_arctype where id=32'}                                                       [field:description/][field:typename/][field:typelink/]                                           {/dede:sql}  sql调取:{dede:sql sql='Select * from dede_arctype where id=22'}              <div class="mod am-1">                 [field:typename/]                    <div class="i">[field:content/]</div>                    <p class="m"><a href="[field:typedir/]">了解更多</a></p>              </div>              {/dede:sql}  

tablib中php文件添加description属性,才能调出内容,其余同理。

二十四、arclist调文章序号偶数添加内容

[field:global name='autoindex' runphp='yes']if(@me==2){@me="class='contents-box02'";}else{@me=' class="contents-box" ';}[/field:global]  

二十五、头部二级菜单

<ul class="navs clearfix">                  <li><a href="{dede:global.cfg_cmsurl/}/" class="nav_current">网站首页<i></i><span></span></a></li>                  {dede:channelartlist typeid="top" cacheid='channelsonlist' type='top' row='10'}                  <li><a href="{dede:field name="typeurl"/}" >{dede:field name="typename"/}<i></i><span></span></a>                      <div class="subNav">                          <div class="lt">                              <h3>{dede:field name="description"/}</h3>                              <h2>{dede:field name="typename"/}</h2>                          </div>                          <div class="rt">                              {dede:channel type="son" noself='yes'}                               <a href="[field:typeurl/]">[field:typename/]</a>                               {/dede:channel}                           </div>                      </div>                  </li>                  {/dede:channelartlist}              </ul>  

二十六、搜索表单(search.htm模板)

搜索内容:{dede:global name='keyword' function='RemoveXSS(@me)'/}列表内容:{dede:list perpage='10'}     <li><span>[field:stime/]</span>   <a href="[field:arcurl/]" target="_blank">[field:title/]</a></li>    {/dede:list}  

二十七、封面调取栏目名与描述

<span class="leftTitle"><s>{dede:field name='typeid' function="GetTopDescription(@me)" /}</s><i>{dede:field name='typeid' function="GetTopTypename(@me)" /}</i></span>  修改include/common.func.php文件,末尾添加自定义方法:function GetTopTypename($id)  {      global $dsql;      $row = $dsql->GetOne("SELECT typename,topid FROM dede_arctype WHERE id= $id");      if ($row['topid'] == '0')      {          return $row['typename'];      }      else      {          $row1 = $dsql->GetOne("SELECT typename FROM dede_arctype WHERE id= $row[topid]");          return $row1['typename'];      }  }  function GetTopDescription($id)  {      global $dsql;      $row = $dsql->GetOne("SELECT description,topid FROM dede_arctype WHERE id= $id");      if ($row['topid'] == '0')      {          return $row['description'];      }      else      {          $row1 = $dsql->GetOne("SELECT description FROM dede_arctype WHERE id= $row[topid]");          return $row1['description'];      }  }  

二十八、去除版权信息
include/dedesql.class.php 第588行

// $arrs1 = array(0x63,0x66,0x67,0x5f,0x70,0x6f,0x77,0x65,0x72,0x62,0x79);  // $arrs2 = array(0x20,0x3c,0x61,0x20,0x68,0x72,0x65,0x66,0x3d,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,  // 0x77,0x77,0x77,0x2e,0x64,0x65,0x64,0x65,0x63,0x6d,0x73,0x2e,0x63,0x6f,0x6d,0x20,0x74,0x61,0x72,  // 0x67,0x65,0x74,0x3d,0x27,0x5f,0x62,0x6c,0x61,0x6e,0x6b,0x27,0x3e,0x50,0x6f,0x77,0x65,0x72,0x20,  // 0x62,0x79,0x20,0x44,0x65,0x64,0x65,0x43,0x6d,0x73,0x3c,0x2f,0x61,0x3e);  //特殊操作  

二十九、列表页调取栏目并高亮显示

<h2 class="leftTitle"><s>{dede:field name='typeid' function="GetTopDescription(@me)" /}</s><i>{dede:field name='typeid' function="GetTopTypename(@me)" /}</i></h2>                  <div class="menu">                      <dl>                          {dede:channel type='son' currentstyle="                            <dt><a href='~typelink~' class='thisclass current'>~typename~</a></dt>                            "}                          <dt><a href="[field:typeurl/]">[field:typename/]<em></em></a></dt>                          {/dede:channel}                       </dl>                  </div>  

三十、菜单高亮currentstyle添加其他字段keywords等:
修改文件include/tablib/channel.lib.php第140行

$linkOkstr = $currentstyle;                      $row['typelink'] = GetOneTypeUrlA($row);                      $linkOkstr = str_replace("~rel~",$row['rel'],$linkOkstr);                      $linkOkstr = str_replace("~id~",$row['id'],$linkOkstr);                      $linkOkstr = str_replace("~typelink~",$row['typelink'],$linkOkstr);                      $linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);                      $linkOkstr = str_replace("~keywords~",$row['keywords'],$linkOkstr);                      $likeType .= $linkOkstr;  使用:{dede:channel type='top' row='10' currentstyle="<li><a href='~typelink~' class='now'><span>~keywords~</span><span>~typename~</span></a> </li>"}          <li><a href='[field:typelink/]'><span class="en">[field:keywords/]</span><span class="ch yaheis">[field:typename/]</span></a> </li>         {/dede:channel}   

三十一、移动端搜索跳转PC端;

首先打开php文件plus/search.php,代码全部复制,然后新建一个文件名为search_m.php的文件,把search.php里面的代码全部粘贴进去。search_m.php还是放在plus目录里面。然后打开php文件include/arc.searchview.class.php复制全部代码,新建一个文件include/arc.searchview.classm.php代码粘贴进去。后面就是修改一下php文件了,打开search_m.php文件,里面第13require_once(DEDEINC."/arc.searchview.class.php");修改为require_once(DEDEINC."/arc.searchview.classm.php");然后打开include/arc.searchview.classm.php文件,找到第131$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/search.htm";修改为$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/search_m.htm";最后修改前台form表单中跳转 action="/plus/search_m.php"
原创粉丝点击