雷火电竞-中国电竞赛事及体育赛事平台

歡迎來到入門教程網!

phpcms

當前位置:主頁 > CMS教程 > phpcms >

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

來源:本站原創(chuàng)|時間:2020-01-10|欄目:phpcms|點擊:

第一步:
后臺添加一個菜單,如下填寫:

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

復制代碼
代碼如下:

<?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();
//欄目級別選項
$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;
//讀站點緩存
$siteid = $this->siteid;
$sitecache = getcache('sitelist','commons');
//根據當前站點,取得文件存放路徑
$systemconfig = pc_base::load_config('system');
$html_root = substr($systemconfig['html_root'], 1);
//判斷當前站點目錄,是PHPCMS則把文件寫到根目錄下, 不是則寫到分站目錄下.(分站目錄用由靜態(tài)文件路經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';
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('當前站點網站地址成功!');
}
}
?>

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

復制代碼
代碼如下:

{template 'content','header'}
<div id="main_full">
<div id="position"><a href="">首頁</a>網站地圖</div>
<div id="sitemap">
{loop $CATEGORYS $childid $c}
{php $arrcats = explode(',',$c[arrparentid]);}
{if in_array($catid,$arrcats)}<!-- 判斷只有子欄目的 -->
{if $c['ismenu']==1}<!-- 判斷欄目是否設置顯示 -->
<a href="{$c[url]}">{$c[catname]}</a>
{/if}
{/if}
{/loop}
</p>
{/if}
<!-- 判斷沒有子欄目且設置顯示的 -->
{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'}

上一篇:修改PHPCMS頭部標題標簽{$head[title]}順序

欄    目:phpcms

下一篇:mysql更改密碼后 配置文件應該改的東西 PHPCMS2008&amp;V9

本文標題:phpcms v9網站生成sitemap靜態(tài)地圖頁面操作步驟

本文地址:http://www.jygsgssxh.com/a1/phpcms/9938.html

網頁制作CMS教程網絡編程軟件編程腳本語言數據庫服務器

如果侵犯了您的權利,請與我們聯(lián)系,我們將在24小時內進行處理、任何非本站因素導致的法律后果,本站均不負任何責任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網 版權所有