phpcms生成的靜态頁目錄規則是按照url規則生成的, 靜态頁 内容是ob_clean前台模闆檔案産生的phpcms\templates\default,靜态頁的調試 :修改靜态頁,重新生成靜态頁再看效果,也可以調用前台控制/index.php?m=openservice&c=index&a=openservice修改好前台模闆再生成。隻要是靜态頁的連結都要及時同步檔案,防止死連結,資料錯誤
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicmbw5ichR3cf52bjl2LcNXZnFWbp9CXt92YuUWelRXauYjM5cmbvlXZkVHavw1LcpDc0RHaiojIsJye.png)
1.
$urlrule = $site_info['domain'].'/webgame/index.html~'.$site_info['domain'].'/webgame/page_{$page}.html';
2.
define('urlrule', $site_info['domain'].'/webgame/{$webgamedir}/index.html~'.$site_info['domain'].'/webgame/{$webgamedir}/spec_{$page}.html');
$globals['url_array'] = array('webgamedir'=>$filename);
背景生成靜态頁的類phpcms\modules\*\classes\html.class.php,在背景控制器中調用
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicmbw5ichR3cf52bjl2LcNXZnFWbp9CXt92YuUWelRXauYjM5cmbvlXZkVHavw1LcpDc0RHaiojIsJye.png)
/**
* 生成開服首頁
*/
public function create_index() {
$html = pc_base::load_app_class('html');
$size = $html->create_list();
showmessage(l('index_create_finish',array('size'=>sizecount($size))));
}
$html = pc_base::load_app_class('html', 'content'); 調用content下的html.class.php
array_shift遞歸調用批量生成靜态頁
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicmbw5ichR3cf52bjl2LcNXZnFWbp9CXt92YuUWelRXauYjM5cmbvlXZkVHavw1LcpDc0RHaiojIsJye.png)
/**
* 生成靜态檔案
* @param string $file 檔案路徑
* @return boolen/intval 成功傳回生成檔案的大小
*/
private function create_html($file) {
$data = ob_get_contents();
ob_end_clean();
pc_base::load_sys_func('dir');
dir_create(dirname($file));
$strlen = file_put_contents($file, $data);
@chmod($file, 0777);
return $strlen;
}
* 生成清單頁
public function create_list() {
$siteid = get_siteid();
//分站時計算路徑
if ($siteid>1) {
$site_info = $this->site->get_by_id($siteid);
$file = pc_base::load_config('system', 'html_root').'/'.$site_info['dirname'].'/openservice/index.html';
} else {
$file = pc_base::load_config('system', 'html_root').'/openservice/index.html';
}
$this->queue->add_queue('add', $file, $siteid);
$file = phpcms_path.$file;
ob_start();
include template('openservice', 'index');
return $this->create_html($file);
}
//生成專題首頁控制中心
public function public_create_html() {
$specials = getcache('create_specials', 'commons');
if (is_array($specials) && !empty($specials)) {
$specialid = array_shift($specials);
setcache('create_specials', $specials, 'commons');
$this->create_index($specialid);
delcache('create_specials', 'commons');
showmessage(l('update_special_success'), '?m=special&c=special&a=init');
//生成某專題首頁
private function create_index($specialid) {
$info = $this->db->get_one(array('id'=>$specialid));
$html = pc_base::load_app_class('html');
$html->_index($specialid);
showmessage($info['title'].l('update_success'), '?m=special&c=special&a=public_create_html');
最近發現網站的生成的網頁根目錄太深了,就簡單了編寫了一個生成url規則到
擴充 > url規則管理 > 增加規則
首先添加一個欄目/清單頁url生成規則
第二步:再添加一個内容頁url生成規則
最後一步:在欄目管理裡面進行html生成管理
在内容管理—欄目管理,點開相差的欄目具體設定那裡,赫然看到html設定 。這才豁然開朗。仿佛是曲徑通幽處了,官方為了把不同的欄目可以設定為不同的模式,分别設 置為靜态或動态網頁,是以,把設定的方法直接細化到了欄目管理裡邊去了。而不是統一的全局設定。跟上程式員的設計思路,這才是最重要的事
下面我們以一個執行個體來講解phpcms v9 欄目的添加和設定相關内容。執行個體:向phpcms v9 預設欄目 國内 下面添加子欄目 軍事新聞 和 政治新聞
說明:如果管理欄目頁沒有預設欄目,請于管理界面右上角更新緩存。
接下來填寫欄目名稱和目錄,以及設定生成html設定選項,如下圖所示:
欄目模版的選擇設定,如下圖所示:
關于phpcms v9 欄目設定的seo和收費設定比較簡單,就不再介紹,下面介紹一下,欄目權限設定,如下圖所示:
說明: 此處的配置設定菜單下,管理者設定->角色設定 相對應。
欄目添加完以後,最後不要忘記更新欄目緩存,否則會引起一些未知錯誤,如下圖所示:
說明:單網頁和外部連結 ,基本和添加普通欄目是一樣的設定。在這裡就不再介紹。