本文整理汇总了PHP中Sitemap::createSitemap方法的典型用法代码示例。如果您正苦于以下问题:PHP Sitemap::createSitemap方法的具体用法?PHP Sitemap::createSitemap怎么用?PHP Sitemap::createSitemap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sitemap
的用法示例。
在下文中一共展示了Sitemap::createSitemap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
<?php
include $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'lib_db.php';
$sm = new Sitemap();
$sm->createSitemap();
class Sitemap
{
private $SITE_NAME = '';
private $CHANGE_FREQ = 'weekly';
private $VM_PRODUCT_SUFFIX = "-detail";
private $SITEMAP_FILE_NAME = "sitemap.xml";
private $PRIORITY = '1';
private $db;
private $table_prefix = '';
public function __construct()
{
$this->SITE_NAME = "http://" . $_SERVER['SERVER_NAME'];
$this->db = new Dbprocess();
$this->db->connectToDb();
$this->table_prefix = $this->db->getTablePrefix();
}
public function createSitemap()
{
$where = "published = 1 and menutype = 'mainmenu' and access IN (1)";
$result = $this->db->select($this->table_prefix . "menu", "*", "{$where}", 'std');
$dom = new DOMDocument('1.0');
$dom->formatOutput = true;
$root = $dom->createElement('urlset');
$root = $dom->appendChild($root);
$ns = $dom->createAttributeNS("http://www.sitemaps.org/schemas/sitemap/0.9", "xmlns");
foreach ($result["value"] as $row) {
示例2: getZixunUrl
$content = '';
foreach($urlList as $url)
{
$content .= '<url>
<loc>'.$url.'</loc>
<lastmod>'.XDateTime::now()->toShortString().'</lastmod>
<changefreq>daily</changefreq>
<priority>0.4</priority>
</url>';
}
return $content;
}/*}}}*/
private function getZixunUrl()
{/*{{{*/
$urlList = array();
$zixunData = array(1,2,3,4,5,6,7,8,9,10,11,1110,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,37,38,39,40,41,42,43,44,45,55,56,57,61);
foreach($zixunData as $data)
{
$urlList[] = 'http://zixun.haodf.com/index/'.$data.'.htm';
}
return $urlList;
}/*}}}*/
}
$sitemap = new Sitemap();
$sitemap->createSitemap();
?>