breadcrumb
.breadcrumb > li {
display: inline-block;
}
.breadcrumb > li + li:before {
padding: 0 5px;
color: #ccc;
content: "/\00a0";
}
.breadcrumb > .active {
color: #777;
}
301跳转
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^alksc.com$
RewriteRule ^(.*)$ http://www.alksc.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/index\.html$
RewriteRule ^(.*)$ / [R=301,L]
</IfModule>
手机网站跳转
<script type="text/javascript">
var browser = {
versions : function() {
var u = navigator.userAgent, app = navigator.appVersion;
return {//移动终端浏览器版本信息
mobile : (!!u.match(/AppleWebKit.*Mobile/) || !!u.match(/Windows Phone/) || !!u.match(/Android/) || !!u.match(/MQQBrowser/)) && !u.match(/iPad/)
//是否为移动终端
};
}()
}
if(browser.versions.mobile){
window.location.href="/mobile/";
}
</script>
引入swiper轮播
<link href="https://cdn.bootcss.com/Swiper/4.3.5/css/swiper.min.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/Swiper/4.3.5/js/swiper.min.js"></script>
<div class="swiper-container">
<div class="swiper-wrapper">
{dede:channel typeid='1' type='son' row='3'}<div class="swiper-slide"><img src="[field:typeimg/]" /></div> {/dede:channel}
</div>
<div class="swiper-pagination"></div>
</div>
<script>
var mySwiper = new Swiper('.swiper-container', {
autoplay: {
delay: 2000,
stopOnLastSlide: false,
disableOnInteraction: true,
},
pagination: {
el: '.swiper-pagination',
clickable :true,
},
})
</script>
.swiper-slide{
height:auto !important;
}
.swiper-slide img{
width:100%;
height:auto;
}
基础设置
alter table `dede_arctype` change `typename` `typename` char(60);
alter table `dede_archives` change `title` `title` varchar(200);
alter table `dede_archives` change `description` `description` varchar(1000);
alter table `dede_arctype` change `description` `description` char(250);
alter table `dede_arctype` add `typeimg` char(100) NOT NULL default '';
<title>{dede:global.cfg_webname/}</title>
<meta name="keywords" content="{dede:global.cfg_keywords/}" />
<meta name="description" content="{dede:global.cfg_description/}" />
<title>{dede:field.title/}_{dede:global.cfg_gsmz/}</title>
<meta name="keywords" content="{dede:field name='keywords'/}" />
<meta name="description" content="{dede:field name='description' function='html2text(@me)'/}" />
<title>{dede:field.seotitle /}_{dede:global.cfg_gsmz/}</title>
<meta name="keywords" content="{dede:field name='keywords'/}" />
<meta name="description" content="{dede:field name='description' function='html2text(@me)'/}" />
<title>{dede:field.seotitle /}_{dede:pagelist listsize="0" listitem="pageno" function="html2text(@me)" runphp="yes"}@me="第".str_replace(' ','',@me)."页";{/dede:pagelist}_{dede:global.cfg_gsmz/}</title>
<meta name="keywords" content="{dede:field name='keywords'/}" />
<meta name="description" content="{dede:field name='description' function='html2text(@me)'/}" />
根目录
{dede:global.cfg_templets_skin/}/
引入foot文件
{dede:include filename='foot.htm'/}
引入head文件
{dede:include filename='head.htm'/}
引用后台基本参数
{dede:global.poweredby/}
调用带logo的友情链接
{dede:sql sql="Select * From youbook_flink where logo = '' order by id desc"}
<a target="_blank" href="[field:url/]" title="[field:webname/]" class="a1">[field:webname/]</a>
{/dede:sql}
文章描述
[field:description function="cn_substr(@me,280)"/]
{dede:field.description function="cn_substr(@me,280)"/}
日期
- 自定义日期
[field:pubdate function='strftime("%m-%d","@me")' /]
- 常用日期
[field:pubdate function="GetDateMK(@me)"/]
{dede:field.pubdate function="GetDateMK(@me)"/}
翻页精简版
{dede:pagelist listitem="pre,next,pageno listsize="5"/}
翻页完整版
//{dede:pagelist listitem="info,index,end,pre,next,pageno,option listsize="5"/}
[field:description function="cn_substr(@me,280)"/]
{dede:field.description function="cn_substr(@me,280)"/}
调用指定栏目链接
{dede:type typeid='1'}[field:typelink/]{/dede:type}
调用指定栏目名称
{dede:type typeid='1'}[field:typename/]{/dede:type}
调用指定id栏目内容
{dede:sql sql='Select content from sh_arctype where id=1'}[field:content function="cn_substr('@me',1200)" /]{/dede:sql}
翻页
- 上一篇:
{dede:prenext get='pre'/}
- 下一篇:
{dede:prenext get='next'/}
面包屑
{dede:field.position/}
自增autoindex
arclist 标签下使用 [field:global.autoindex/] 默认从1开始
channel 标签下使用 [field:global.autoindex/] 默认从0开始
channelartlist 标签下使用 {dede:global.itemindex/} 默认从1开始
arclist 从0开始[field:global name=autoindex runphp="yes"]@me=@me-1;[/field:global]
channel 从1开始[field:global name=autoindex runphp="yes"]@me=@me+1;[/field:global][field:typename/]
channelartlist 从0开始{dede:global name=itemindex runphp='yes'}@me=@me-1;{/dede:global}
表单的alert
echo "<script>alert('提交成功!'); history.go(-1)</script>";
统计该栏目下有多少新闻标题
{dede:type typeid='9'}[field:id function="dynamic_num(@me)" /]{/dede:type}条
列表页调用文章内容
之后就可以在列表页的文章列表中调用文章内容了,代码如下:先要在内容模型把body填写到内容附加字段里
{dede:list pagesize='18' addfields='body'}
[field:body/]
{/dede:list}
调用内容到首页
- 首页调用单页内容(例如调用公司简介、联系我们)
如公司简介、联系我们这样的单页面,调用其中全部内容可以使用代码代码,其中id可以控制调用指定id的栏目。
{dede:sql sql='Select content from dede_arctype where id=2'}
[field:content/]
{/dede:sql}
- 调用单页内容(和上面代码差不多,只是更换了中间代码)
第一种方法可以调用单页所有内容,包括单页内容的图片、格式等,全部调用。但如果我们只想调用单页的部分文字,可以用下面代码:
{dede:sql sql='Select content from dede_arctype where id=2' }
[field:content function='cn_substr(html2text(@me),550)'/]...
{/dede:sql}
- 在首页调用文章内容
上面两种方法是在首页调用单页栏目的内容,如果我们想在首页调用文章内容,就需要用下面代码,其中typeid=2是调用id=2的栏目的最新文章。
{dede:sql sql="SELECT aid,typeid,body FROM `#@__addonarticle` where typeid=2 ORDER BY `aid` DESC LIMIT 0 , 1"}
[field:body /]
{/dede:sql}
搜索页样式修改
/include/arc.searchview.class.php
获取当前文章id
{dede:sql sql='Select * from baoan_addonarticle where aid=~aid~'}[field:aid/]{/dede:sql}
当前文章栏目高亮
{dede:arclist typeid='6' row='52' titlelen='250'}
<li><a href="[field:arcurl/]" id="a_[field:id/]">[field:title/]</a></li>
{/dede:arclist}
<input type="hidden" value="{dede:sql sql='Select * from baoan_addonarticle where aid=~aid~'}[field:aid/]{/dede:sql}" id="aaid"/> //增加一个隐藏的input来获取当前文章的id
<input type="hidden" value="{dede:sql sql='Select * from jietong_arctype where id=~id~'}[field:id/]{/dede:sql}" id="aaid"/>//增加一个隐藏的input来获取当前栏目的id
<input type="hidden" value="{dede:field.typeid/}" id="aaid"/>//增加一个隐藏的input来获取当前文章对应的栏目的id
$(document).ready(function(){
var ccid=$("#aaid").val();
$("#a_"+ccid).addClass("a");
});
修改友情链接
打开/include/taglib
搜索{dede:flink linktype='1' typeid='4' row='999'}[field:link /]{/dede:flink}
typeid='4'
表示类型
linktype='1'
表示位置 首页
{dede:flink linktype='1' typeid='4' row='999'}[field:link /]{/dede:flink}
调用特定id文章的描述
{dede:sql sql="SELECT id,typeid,description FROM `azqy_archives` where id=6"}
[field:description /]
{/dede:sql}
调用指定id文章
{dede:arclist typeid='2' idlist='7'}[field:title/]{/dede:arclist}
获取顶级栏目名
- 在
include/common.func.php
的最下方加入:
//获取顶级栏目名
function GetTopTypename($id)
{
global $dsql;
$row = $dsql->GetOne("SELECT typename,topid FROM geer_arctype WHERE id= $id");
if ($row['topid'] == '0')
{
return $row['typename'];
}
else
{
$row1 = $dsql->GetOne("SELECT typename FROM geer_arctype WHERE id= $row[topid]");
return $row1['typename'];
}
}
- 调用语句:
{dede:field name='typeid' function='GetTopTypename(@me)' /}
信息发布员自行修改密码
/admin/sys_admin_user_edit.php
第23行CheckPurview('sys_User');
改成CheckPurview('sys_MdPwd');
<!--带0的arclist的自动生成数字-->
[field:global name=autoindex runphp="yes"](@me<10)?@me="0@me":@me="10";[/field:global]
修改数据表以后无法删除文章
其中ddth
是修改以后的数据表的名称
update ddth_channeltype set maintable='ddth_archives'
搜索
<form name="formsearch" action="/plus/search.php" method="post" onsubmit="return validator()">
<input name="q" type="text" id="search-keyword" value="请输入关键词..." onfocus="if(this.value=='请输入关键词...'){this.value='';}" onblur="if(this.value==''){this.value='请输入关键词...';}" />
<input value="搜 索" type="submit" />
</form>
function validator(){
if($('#search-keyword').val()=="请输入关键词..."||$('#search-keyword').val()==""||$.trim($('#search-keyword').val()).length==0){
alert("请输入关键词!");
$('#search-keyword').focus();
return false;
}
}
调用顶级栏目以及子栏目
<li class="nav_lev1"> <a href="/" {dede:field name=typeid runphp="yes"}(@me=="")? @me=" class='menu1 active' ":@me="";{/dede:field}>网站首页 </a> </li>
{dede:channelartlist typeid='top' currentstyle='active' row='6'}
<li class="nav_lev1">
<a href="{dede:field name='typeurl'/}" class="menu1 {dede:field.currentstyle/}">
{dede:field name='typename'/}
{dede:field name=typeid runphp="yes"}
global $dsql;
$sql = "SELECT id From `dede_arctype` WHERE reid='@me' And ishidden<>1 order by sortrank asc limit 0, 100 ";
$row = $dsql->GetOne($sql);
@me=is_array($row)?'<i class="fa fa-caret-down"></i>':'';
{/dede:field}
</a>
<ul {dede:field name=typeid runphp="yes"} global $dsql;
$sql = "SELECT id From `#@__arctype` WHERE reid='@me' And ishidden<>1 order by sortrank asc limit 0, 100 ";
$row = $dsql->GetOne($sql);
@me=is_array($row)?'class="drop-down sub-menu2"':'style="display:none"';
{/dede:field}>
{dede:channel type='son' noself='yes'}
<li class="Lev2"> <a href="[field:typeurl/]" class="menu2">[field:typename/]</a> </li>
{/dede:channel}
</ul>
</li>
{/dede:channelartlist}
首页自定义字段
{dede:myad name='广告位标识 '/}
调用指定栏目ID的栏目名称
{dede:type typeid='2'}<a href="[field:typelink/]">[field:typename/]</a>{/dede:type}
调用指定栏目及其子栏目两种方法
{dede:channelartlist typeid='2,3' row='6'}
<li><a class="hide" href="{dede:field name='typeurl'/}">{dede:field name='typename'/}</a>
<ul>
{dede:channel type='son' noself='yes' }
<li><a href='[field:typelink/]'>[field:typename/]</a></li>
{/dede:channel}
</ul>
</li>
{/dede:channelartlist}
<li>{dede:type typeid='5'}<a href='[field:typelink/]'>[field:typename/]</a>{/dede:type}
<ul>
{dede:channel type='son' typeid='5' noself='yes' }
<li><a href='[field:typelink/]'>[field:typename/]</a></li>
{/dede:channel}
</ul>
</li>
dede:arclist
下的附加字段调用
{dede:arclist titlelen='60' row='7' typeid='栏目ID' channelid='附加表的ID' addfields='附加字段'}
<a href="[field:附加字段/]">[field:title/]</a>
{/dede:arclist}
首页调用指定ID文章内容
{dede:arclist titlelen='60' row='1' typeid='栏目ID' channelid='附加表的ID' addfields='附加字段' idlist='文章ID'}
[field:body function='cn_substr("@me",400)' /]
{/dede:arclist}
GetInnerText
织梦DedeCMS在更新列表页html时提示:Fatal error: Call to a member function GetInnerText() on a non-object in \include\taglib\channel\img.lib.php on line 42
往往这个错误提示会在更新自定义模型的栏目列表页html时出现,解决的办法:
- 找到并打开
/include/taglib/channel/img.lib.php
文件,在里面找到如下代码:
$innerTmp = $arcTag->GetInnerText();
- 将其替换为如下代码:
$innerTmp = ($arcTag=="") ? trim($arcTag) : trim($arcTag->GetInnerText());
这样就可以解决这个问题了。