phpcms v9网站生成sitemap静态地图页面 *** 作步骤

phpcms v9网站生成sitemap静态地图页面 *** 作步骤,第1张

phpcmsv9网站生成sitemap静态地图页面 *** 作步骤

Sitemap静态地图有利于搜索引擎蜘蛛的抓取,对于seo优化非常关键。但是,有些站长却忽略了它的存在。接下来将详细介绍静态地图sitemap的形成方法。有兴趣的话可以参考一下,期待对你有所帮助。

第一步:
后台管理加上一个莱单,以下填好:

第二步,将下列编码储存为sitemap.php文档放进phpcmsmodulesadminsitemap.php:

复制代码编码以下:
<?php
defined('IN_PHPCMS')orexit('Nopermissionresources.');
pc_base::load_app_class('admin','admin',0);
pc_base::load_sys_class('form','',0);
classsitemapextendsadmin{
function__construct(){
parent::__construct();
//频道等级选择项
$this->siteid=$this->get_siteid();
$this->categorys=getcache('category_content_'.$this->siteid,'commons');
}
/**
*
*Entergooglesitemap,百度新闻协议书
*/
functioninit(){
$hits_db=pc_base::load_model('hits_model');
$CATEGORYS=$this->categorys;
//读网站缓存文件
$siteid=$this->siteid;
$sitecache=getcache('sitelist','commons');
//依据当今网站,获得文档储放途径
$systemconfig=pc_base::load_config('system');
$html_root=substr($systemconfig['html_root'],1);
//分辨当今网站文件目录,是PHPCMS则把文档写到根目录下,并不是则提到子站文件目录下.(子站文件目录用由静态文档途经html_root和子站文件目录dirname构成)
if($siteid==1){
$dir=PHPCMS_PATH;
}else{
$dir=PHPCMS_PATH.$html_root.DIRECTORY_SEPARATOR.$sitecache[$siteid]['dirname'].DIRECTORY_SEPARATOR;
}
//实体模型缓存文件
$modelcache=getcache('model','commons');
if(!defined('HTML'))define('HTML',1);
//获得当今网站网站域名,下边URL的时候会采用.
$this_domain=substr($sitecache[$siteid]['domain'],0,strlen($sitecache[$siteid]['domain'])-1);
ob_start();
$file=$dir.'sitemap.html';
includetemplate('content','sitemap');
$data=ob_get_contents();
ob_clean();
if(!is_dir($dir)){
mkdir($dir,0777,1);
}
file_put_contents($file,$data);
@chmod($file,0777);
showmessage('当今网站网址取得成功!');
}
}
?>

第三步,将下列编码储存为sitemap.html文档,放进phpcmstemplatesdefaultcontentsitemap.html:

复制代码编码以下:
{template'content','header'}
<divid="main_full">
<divid="position"><ahref="">主页</a>网址地图</div>
<divid="sitemap">
{loop$CATEGORYS$childid$c}
{php$arrcats=explode(',',$c[arrparentid]);}
{ifin_array($catid,$arrcats)}<!--分辨仅有子频道的-->
{if$c['ismenu']==1}<!--分辨频道是不是设定显示信息-->
<ahref="{$c[url]}">{$c[catname]}</a>
{/if}
{/if}
{/loop}
</p>
{/if}
<!--分辨沒有子频道且设定显示信息的-->
{if$cat['child']==0and$cat['parentid']==0and$cat['ismenu']==1}
<h3>{$child}<ahref="{$cat[url]}">{$cat[catname]}</a>{$parentid}</h3>{/if}
{/loop}</div>
</div>
{template'content','footer'}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/773057.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-03
下一篇 2022-05-03

发表评论

登录后才能评论

评论列表(0条)

保存