修改/application/common.php 文件,找到sitemap_xml函數(shù);增加下面代碼:
$result_citysite = M('citysite')->field("*")
->order('sort_order asc, id asc')
->getAllWithIndex('id');
/*地區(qū)*/
foreach ($result_citysite as $sub) {
if (is_array($sub)) {
$url = "你的域名/".$sub['domain'].'/';
$url = str_replace('&', '&', $url);
$url = str_replace('&', '&', $url);
if ($web_mobile_domain_open){ //兩個(gè)域名,生成兩次,移動(dòng)端添加標(biāo)簽:<mobile:mobile type="mobile"/>
$xml = join_xml($xml,$url,$now,$sitemap_changefreq_list,$sitemap_priority_list,'pc');
array_push($urls_txt, htmlspecialchars_decode($url));
if($xml_mobile){
$url = get_typeurl($sub, false,'mobile'); //pc_to_mobile_url($url,$sub['id']);
$url = str_replace('&', '&', $url);
$url = str_replace('&', '&', $url);
$xml_mobile = join_xml($xml_mobile,$url,$now,$sitemap_changefreq_index,$sitemap_priority_index,'mobile');
array_push($urls_txt_mobile, str_replace('.xml', '.txt', htmlspecialchars_decode($url)));
}
}else{ //一個(gè)域名
if ($response_type){ //pc、移動(dòng)端分離 <mobile:mobile type="pc,mobile"/>
$xml = join_xml($xml,$url,$now,$sitemap_changefreq_list,$sitemap_priority_list,'htmladapt');
}else{ //代碼適配 <mobile:mobile type="htmladapt"/>
$xml =join_xml($xml,$url,$now,$sitemap_changefreq_list,$sitemap_priority_list,'pc,mobile');
}
array_push($urls_txt, htmlspecialchars_decode($url));
}
}
}
/*--end*/
這是個(gè)比較簡(jiǎn)單直接的方法