帝国CMS创建网站地图Sitemap.xml文件

在后台找到自定义页面,添加自定义页面,可直接复制下面的代码放入页面内容内即可。文件名选择存放路径:../../sitemap.xml

<?='<?xml version="1.0" encoding="UTF-8"?>'?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>[!--news.url--]</loc>
<lastmod> <?php echo date("Y-m-d"); ?></lastmod>
<changefreq>daily</changefreq>
<priority>1.000</priority>
</url>
[e:loop={"select * from [!db.pre!]enewsclass order by myorder",0,24,0}]
<?
if($bqr['classurl']=='')
{
$sccurl=$public_r['newsurl'].$bqr['classpath']."/";
}
else
{
$sccurl=$bqr['classurl']."/";
}
?>
<url>
<loc><?=$sccurl?></loc>
<changefreq>daily</changefreq>
<priority>0.8000</priority>
</url>
[/e:loop]
[e:loop={"select * from [!db.pre!]enewszt order by ztid",0,24,0}]
<?
if($bqr['zturl']=='')
{
$sccurl=$public_r['newsurl'].$bqr['ztpath']."/";
}
else
{
$sccurl=$bqr['zturl']."/";
}
?>
<url>
<loc><?=$sccurl?></loc>
<lastmod><?=date('Y-m-d',$bqr[newstime])?></lastmod>
<changefreq>monthly</changefreq>
<priority>0.6000</priority>
</url>
[/e:loop]
[e:loop={"select * from [!db.pre!]ecms_news order by newstime desc",0,24,0}]
<url>
<loc><?=$bqsr[titleurl]?></loc>
<lastmod><?=date('Y-m-d',$bqr[newstime])?></lastmod>
<changefreq>monthly</changefreq>
<priority>0.5000</priority>
</url>
[/e:loop]
</urlset>

上面设置之后就创建了地图生成页面,如果运行正常,那么在保存的时候就会自动在根目录创建sitemap.xml文件,如果没有自动创建文件请检查根目录是否有写入权限。

另外,可以设置自动刷新任务,添加新的定时刷新计划任务,来保持sitemap.xml的自动更新。

Html Table自适应宽度,指定列固定宽度,其他列均分宽度

做表单界面时,我想到最好的方法应该是,标题栏所在的列宽度固定,内容栏所在的列宽度自适应且要均分,这样整体表格看起来才美观有序。

要做到这一点,目前只摸索出一种办法:
1,给tabletable-layout: fixed;
2,在每个table的第一行,加<colgroup><col>,有多少列,对应加多少个<col>
3,给指定列固定宽度的<col>加成<td class="title">,然后给title定义宽度,其他列的<col>加成<col width="auto">

案例代码:

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>案例文档</title>
  <style>
    table{
      width: 100%;
      border-collapse: collapse;
      border: 1px solid #000;
      word-break:break-word;
      word-wrap:break-word;
      table-layout: fixed;
    }
    table tr td{
      border: 1px solid #000;
    }
    .title {
      background-color: #eee; 
      width: 120px;
      text-align: center;
    }
  </style>
</head>
<body>
  <table>
    <colgroup>
      <col class="title">
      <col width="auto">
      <col class="title">
      <col width="auto">
    </colgroup>
    <tr>
      <td class="title">标题:</td>
      <td colspan="3"></td>
    </tr>
    <tr>
      <td class="title">标题:</td>
      <td>内容</td>
      <td class="title">标题:</td>
      <td></td>
    </tr>
    <tr>
      <td class="title">标题:</td>
      <td colspan="3"></td>
    </tr>
    <tr>
      <td class="title">标题:</td>
      <td>内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容</td>
      <td class="title">标题:</td>
      <td></td>
    </tr>
  </table>
</body>
</html>

注意:这里有一个问题,有可能你程序没法在table的第一行<tr>前面加<colgroup><col>,比如asp.net的webform里面就不知道怎么加,此时的变通方法是,把<colgroup><col>换成一个空的<tr><td>,在<td>上同样加对应的class和width属性,然后通过样式把这个空行的边框和高度去掉,不显示。

原理:通过控制第一行各个列的宽度,来实现对整个表格的列进行控制。

本文摘自:http://www.dongchuanmin.com/archives/677.html

Linux系统使用iftop查看带宽占用情况

Linux系统下如果服务器带宽跑满了,查看跟哪个ip通信占用带宽比较多,可以通过iftop命令进行查询,使用方法如下:

1 安装方法【软件官网地址:http://www.ex-parrot.com/~pdw/iftop/
CentOS系统运行:yum install iftop
Debian系统运行:apt-get install iftop

在安装过程中需要我们输入 y 继续的步骤,在安装过程中会提醒我们的。安装完毕之后,就可以使用iftop命令激活监控。

2 安装好后在服务器执行iftop -i eth1就可以查看服务器公网网卡带宽使用情况(如果只执行iftop默认检测第一块网卡使用情况,这样查的会是内网网卡eth0。
执行:iftop -i eth0 -p
注:-P 参数会将请求服务的端口显示出来,也就是说是通过服务器哪个端口建立的连接,看内网流量执行 iftop -i eth0 -P 命令。

帝国CMS屏蔽在/d/file/附件文件夹下创建栏目目录的方法

如果网站的栏目较多,图片上传保存的文件夹是不太适合存在栏目目录下的,我喜欢存在/d/file/Y-m/,放在统一的文件夹下,而且按年月目录存放,设置如下:
ecms01.png

但是有一个问题就是,每次在后台执行 “数据更新 → 恢复栏目目录” 时,程序就会自动在/d/file/附件文件夹下创建网站的所有栏目目录,尤其是当网站栏目很多时,就会造成大量的空目录。

当然你可以不管他,但我有洁癖,看不得那些毫无意义的空目录,屏蔽生成的方法如下:

一、找到文件/e/class/functions.php
二、搜索:function CreateClassPath($classpath)
三、讲执行操作的代码屏蔽掉,如下图:
ecms02.png

本文转自:http://www.dongchuanmin.com/archives/563.html

帝国CMS 用关键字做出Tags链接效果

思路:
1,帝国CMS的关键字一般是用英文逗号分隔,比如:小红,小明,小华
2,需要把英文逗号去掉,并且给每个关键字用html标签包起来,比如:<li>小红</li><li>小明</li><li>小华</li>

代码:

<?php 
$cr=$empire->fetch1("select classpagekey from {$dbtbpre}enewsclass where classid='$GLOBALS[navclassid]'");
$source=$cr[classpagekey];
$hello = explode(',',$source); 
for($index=0;$index<count($hello);$index++) 
{ 
echo "<li><a href='/e/tags/?tagname=$hello[$index]&tempid=8'>"; echo $hello[$index];echo "</a></li>"; 
} 
?>

说明:
1、先把关键字内容取出来
2、用php的explode函数,把字符串打散为数组
3、然后用for循环,把数组中的每个词语用指定的HTML标签包起来

本文转自:http://www.dongchuanmin.com/archives/623.html

利用CSS3媒体查询@media进行响应式页面制作

响应式页面就是根据屏幕尺寸的不同进行不同版面样式的显示。css3的meidia媒体查询的属性可满足该需求的定义。

第一种方式

为不同的屏幕尺寸定义不同的css样式,屏幕尺寸变化时动态调整css。优点是独立定义css文件管理方便,缺点是需要加载多个css文件。

<!--html标签--!>
<link rel="stylesheet" media="(max-width: 900px)" href="sty1.css" />
<link rel="stylesheet" media="(max-width: 700px)" href="sty2.css" />

即屏幕尺寸不超过900px时使用syt1.css样式,同时尺寸不超过700px时使用sty2,css样式。顺序不能反。

第二种方式

采用一个css文件,定义样式时通过@media媒体查询进行区分。优点是一个样式文件搞定多种屏幕需求。

/*css标签*/
@media screen and (max-width:992px){
 body {
  background-color: #FF0000;
 }
}

@media screen and (max-width:768px){
 body {
  background-color: #000000;
 }
}

即可屏幕不超过992px时背景颜色是红色,同时背景颜色不超过768px时背景颜色是黑色。

调试html如下

<style>
/*css标签*/
@media screen and (max-width:992px){
 body {
  background-color: #FF0000;
 }
}

@media screen and (max-width:768px){
 body {
  background-color: #000000;
 }
}
</style>

以上代码进行调试,弹出的窗口进行拖拉缩放时可查看到:页面尺寸小于768px时候网页背景色是黑色,超出768px同时又小于992px时网页背景色是红色。

通过media媒体查询就可以来任意定义当前属性样式在某尺寸分辨率下的具体表现了。