欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

phpcms v9網(wǎng)站生成sitemap靜態(tài)地圖頁(yè)面操作步驟

  發(fā)布時(shí)間:2013-03-11 15:33:33   作者:佚名   我要評(píng)論
網(wǎng)站sitemap靜態(tài)地圖有利于蜘蛛的抓取,對(duì)于seo優(yōu)化來(lái)說(shuō)相當(dāng)重要,不過(guò)某些站長(zhǎng)已忽視了它的存在,接下來(lái)將介紹下靜態(tài)地圖sitemap的生成方法,感興趣的你可以參考下哈,希望可以幫助到你
第一步:
后臺(tái)添加一個(gè)菜單,如下填寫(xiě):

第二步,將以下代碼保存為 sitemap.php 文件放到 phpcmsmodulesadminsitemap.php :

復(fù)制代碼
代碼如下:

<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin','admin',0);
pc_base::load_sys_class('form', '', 0);
class sitemap extends admin {
function __construct() {
parent::__construct();
//欄目級(jí)別選項(xiàng)
$this->siteid = $this->get_siteid();
$this->categorys = getcache('category_content_'.$this->siteid,'commons');
}
/**
*
* Enter google sitemap, 百度新聞協(xié)議
*/
function init() {
$hits_db = pc_base::load_model('hits_model');
$CATEGORYS = $this->categorys;
//讀站點(diǎn)緩存
$siteid = $this->siteid;
$sitecache = getcache('sitelist','commons');
//根據(jù)當(dāng)前站點(diǎn),取得文件存放路徑
$systemconfig = pc_base::load_config('system');
$html_root = substr($systemconfig['html_root'], 1);
//判斷當(dāng)前站點(diǎn)目錄,是PHPCMS則把文件寫(xiě)到根目錄下, 不是則寫(xiě)到分站目錄下.(分站目錄用由靜態(tài)文件路經(jīng)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);
//獲取當(dāng)前站點(diǎn)域名,下面URL時(shí)會(huì)用到.
$this_domain = substr($sitecache[$siteid]['domain'], 0,strlen($sitecache[$siteid]['domain'])-1);
ob_start();
$file = $dir.'sitemap.html';
include template('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('當(dāng)前站點(diǎn)網(wǎng)站地址成功!');
}
}
?>

第三步,將以下代碼保存為 sitemap.html 文件,放到 phpcmstemplatesdefaultcontentsitemap.html :

復(fù)制代碼
代碼如下:

{template 'content','header'}
<div id="main_full">
<div id="position"><a href="">首頁(yè)</a>網(wǎng)站地圖</div>
<div id="sitemap">
{loop $CATEGORYS $childid $c}
{php $arrcats = explode(',',$c[arrparentid]);}
{if in_array($catid,$arrcats)}<!-- 判斷只有子欄目的 -->
{if $c['ismenu']==1}<!-- 判斷欄目是否設(shè)置顯示 -->
<a href="{$c[url]}">{$c[catname]}</a>
{/if}
{/if}
{/loop}
</p>
{/if}
<!-- 判斷沒(méi)有子欄目且設(shè)置顯示的 -->
{if $cat['child']==0 and $cat['parentid']==0 and $cat['ismenu']==1}
<h3>{$child}<a href="{$cat[url]}">{$cat[catname]}</a>{$parentid}</h3>{/if}
{/loop} </div>
</div>
{template 'content','footer'}

相關(guān)文章

最新評(píng)論