聯(lián)系官方銷售客服
1835022288
028-61286886
這個(gè)代碼是怎么弄?才能讓火車頭發(fā)布到數(shù)據(jù)庫文章后自動生成文章的靜態(tài)頁?
上次帖子地址:http://223987.com/wenda/22707.html
下邊的代碼上次作者告訴我的。應(yīng)該是在index.php里開啟開發(fā)者模式。然后把代碼放到哪里???文章id怎么獲取。大家不要見笑,會的話指點(diǎn)下。
《《當(dāng)然下個(gè)版本要是能更新到,檢測到欄目seo里開啟了靜態(tài),并且正常發(fā)布文章后自動生成,就不需要這么麻煩了?!贰?/p>
--------------------------------------------
首先把程序更新到開發(fā)版
dr_html_auth(1); file_get_file(SITE_ID.'index.php?s=news&c=html&m=showfile&id=99999999');
999999改成要生成文章的id號
--------------------------------------------
以下火車頭采集接口的代碼
<?php
$this->_module_init('news'); // news 是模塊目錄
if ($_GET['action'] == 'category') {
// 顯示欄目
foreach ($this->module['category'] as $t) {
if ($t['child'] == 0 && $t['tid'] == 1) {
echo '<h1>'.$t['name'].'<=>'.$t['id'].'</h1>'.PHP_EOL;
}
}
} else {
// 入庫數(shù)據(jù)
$data = $_REQUEST;
// 發(fā)布者id 1
$data['uid'] = 1;
// 發(fā)布者賬號 admin
$data['author'] = 'admin';
// 主表字段
$fields[1] = $this->get_cache('table-'.SITE_ID, $this->content_model->dbprefix(SITE_ID.'_'.MOD_DIR));
$cache = $this->get_cache('table-'.SITE_ID, $this->content_model->dbprefix(SITE_ID.'_'.MOD_DIR.'_category_data'));
$cache && $fields[1] = array_merge($fields[1], $cache);
// 附表字段
$fields[0] = $this->get_cache('table-'.SITE_ID, $this->content_model->dbprefix(SITE_ID.'_'.MOD_DIR.'_data_0'));
$cache = $this->get_cache('table-'.SITE_ID, $this->content_model->dbprefix(SITE_ID.'_'.MOD_DIR.'_category_data_0'));
$cache && $fields[0] = array_merge($fields[0], $cache);
// 去重復(fù)
$fields[0] = array_unique($fields[0]);
$fields[1] = array_unique($fields[1]);
$save = [];
// 主表附表歸類
foreach ($fields as $ismain => $field) {
foreach ($field as $name) {
isset($data[$name]) && $save[$ismain][$name] = $data[$name];
}
}
if (!$data['catid']) {
exit('欄目為空');
}
$save[1]['uid'] = $save[0]['uid'] = $data['uid'];
$save[1]['catid'] = $save[0]['catid'] = $data['catid'];
// 提取內(nèi)容中第一張圖作為縮略圖
$imgs = dr_get_content_img($save[0]['content']);
$save[1]['thumb'] = (string)$imgs[0];
$save[1]['url'] = '';
$save[1]['status'] = 9; //9表示正常發(fā)布,1表示審核里面
$save[1]['hits'] = 0;
$save[1]['displayorder'] = 0;
$save[1]['link_id'] = 0;
$save[1]['comments'] = 0;
$save[1]['avgsort'] = 0;
$save[1]['inputtime'] = $save[1]['updatetime'] = SYS_TIME + rand(0, 7200);
$save[1]['inputip'] = '127.0.0.1';
// 驗(yàn)證標(biāo)題重復(fù)
if ($this->content_model->table(SITE_ID.'_'.MOD_DIR)->where('title', $save[1]['title'])->counts()) {
echo '重復(fù)';exit;
}
$rt = $this->content_model->save(0, $save);
if ($rt['code']) {
exit('成功');
} else {
exit('失敗');
}
}
exit;
回復(fù)迅??蚣軇?chuàng)始人
那就應(yīng)該是把這個(gè)代碼放到采集接口的代碼里吧
if ($rt['code']) {
//增加
//增加
exit('成功');
} else {
exit('失敗');
你語法寫錯(cuò)了