當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Sitemap::createSitemap方法代碼示例

本文整理匯總了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) {
開發者ID:romuland,項目名稱:khparts,代碼行數:31,代碼來源:sitemap.php

示例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();
?>
開發者ID:sdgdsffdsfff,項目名稱:hdf-client,代碼行數:30,代碼來源:sitemap4www.php


注:本文中的Sitemap::createSitemap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。