海洋cms利用海洋cms DIY组件搭建动态sitemap地图教程
不懂代码的可以不用看代码,直接看文字就能理解,非常简单!
1、复制根目录下 diy.php文件一份重命名为你想要的文件
例如 sitemap.php
将如下代码粘贴
<?php
require_once ("include/common.php");
$cs=$_SERVER["REQUEST_URI"];
if($GLOBALS['cfg_mskin']==3 AND $GLOBALS['isMobile']==1){header("locationcfg_mhost$cs");}
if($GLOBALS['cfg_mskin']==4 AND $GLOBALS['isMobile']==1){header("locationcfg_mhost");}
function php_self(){
$php_self=substr($_SERVER['PHP_SELF'],strrpos($_SERVER['PHP_SELF'],'/')+1);
$php_self=str_replace('.php','',$php_self);
return $php_self;
}
$phpself=php_self();
require_once sea_INC."/main.class.php";
echoIndex();
function echoIndex()
{
global $cfg_iscache,$t1,$phpself;
$cacheName="parsed_".$phpself.$GLOBALS['cfg_mskin'].$GLOBALS['isMobile'];
$templatePath="/templets/".$GLOBALS['cfg_df_style']."/".$GLOBALS['cfg_df_html']."/".$phpself.".xml";
if($GLOBALS['cfg_mskin']!=0 AND $GLOBALS['cfg_mskin']!=3 AND $GLOBALS['cfg_mskin']!=4 AND $GLOBALS['isMobile']==1)
{$templatePath="/templets/".$GLOBALS['cfg_df_mstyle']."/".$GLOBALS['cfg_df_html']."/".$phpself.".xml";}
if($cfg_iscache){
if(chkFileCache($cacheName)){
$indexStr = getFileCache($cacheName);
}else{
$indexStr = parseIndexPart($templatePath);
setFileCache($cacheName,$indexStr);
}
}else{
$indexStr = parseIndexPart($templatePath);
}
$indexStr=str_replace("{seacms:member}",front_member(),$indexStr);
echo str_replace("{seacms:runinfo}",getRunTime($t1),$indexStr) ;
}
function parseIndexPart($templatePath)
{
global $mainClassObj;
$content=loadFile(sea_ROOT.$templatePath);
$content=$mainClassObj->parseTopAndFoot($content);
$content=replaceCurrentTypeId($content,-444);
$content=$mainClassObj->parseSelf($content);
$content=$mainClassObj->parseHistory($content);
$content=$mainClassObj->parseGlobal($content);
$content=$mainClassObj->parseAreaList($content);
$content=$mainClassObj->parseNewsAreaList($content);
$content=$mainClassObj->parseMenuList($content,"",$currentTypeId);
$content=$mainClassObj->parseVideoList($content,$currentTypeId,'','');
$content=$mainClassObj->parseNewsList($content,$currentTypeId,'','');
$content=$mainClassObj->parseTopicList($content);
$content=$mainClassObj->parseLinkList($content);
$content=$mainClassObj->parseIf($content);
header("Content-type:text/xml");
return $content;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
说明:其实就是 将.html 修改成.xml 另外在在 71行 增加 header("Content-type:text/xml"); 代码
页可以不将 .html 修改成.xml
2、模板页制作
我们之前将html修改成xml了 那么就需要创建对应XML文件
例如: sitemap.xml 在 根目录//templets/模板目录/html/ 下创建 如没有修改.html 那么直接创建 sitemap.html
3、粘贴代码
<?xml version="1.0" encoding="utf-8"?>
<urlset>
{seacms:videolist type=all num=1000 order=time}
<url>
<loc>http://你自己的域名/[videolist:link]</loc>
<lastmod>[videolist:time style=yyyy-mm-dd]></lastmod>
<changefreq>always</changefreq>
<priority>0.8</priority>
</url>
{/seacms:videolist}
</urlset>
/////////////////////////////////////////////////////////////////////////////////////////////////////////
上面的1000是条数,你可以根据自己情况修改。
这样就实现了动态 地图
/////////////////////////////////////////////////////////////////////////////////////////////////////////
注:新闻模板只需要修改 标签 videolist 替换成 newslist,专题 videolist替换成 topiclist
专题的时间:tiem替换成 addtime
/////////////////////////////////////////////////////////////////////////////////////////////////////////
最后的最后添加伪静态规则
rewrite ^/sitemap.xml$ /sitemap.php last;
完成
直接访问 http://你的域名.com/sitemap.xml 即可
/////////////////////////////////////////////////////////////////////////////////////////////////////////
更多文章
-
海洋cms模板标签大全(收藏级)
海洋cms以其免费开源、采集功能强大著称,吸引了越来越影视站长。那么在使用海洋cms过程中,模板标签是必须要掌握的。下面是整理的海洋cms模板标签大全,对于做站朋友,一定有用,赶快收藏起来吧!海洋cms模板标签目录00.相关必要说明 01.全局标签 02.自定义标签 03.if标签和嵌套if标签subif(支持php语句、多e
-
海洋cms模板更换及安装教程
很多刚使用海洋cms站长朋友,不知道如何更换模板及安装,下面就详细的图文教程,快来学习! 第一步,从免费海洋cms模板下载网站(http://www.dongliancnc.com),选择喜好的模板并下载,特别说明都是人工测试过的模板,保证使用哦。 第二步,将模板压缩包,上传文件到网站templets目录下
-
海洋cms海洋默认模板首页banner是更具什么来推荐生成的
用的是海洋的默认模板,请问各位老大, 首页banner是更具什么来推荐生成的,我试了把点击数量调大, 但是并不是都进入了首页的banner里,不知道是受什么影响的 解决方法: 每个模板都不一样,根据模板实际调用的内容来决定。 一般情况下是根据星级。 配合模板标签检查
-
海洋cms安装引导连不上数据库
使用虚拟主机安装的海洋cms,根据安装包内伪静态规则记载“** IIS和Apache的伪静态规则后台直接自动生成” 虚拟主机应使用Apache的伪静态且自动生成,但安装引导一直提示数据库连接失败,已查证数据库信息无误 解决方法: 数据库连接失败,肯定还是你的数据库信息填写有问题。找idc核实下
-
海洋cmscentos7宝塔自动采集报错
/www/server/cron/accbb9db7a4fb6706e8a35c927af770d: line 12: web_site: command not found /www/server/cron/accbb9db7a4fb6706e8a35c927af770d: line 15: