How to create sitemap for static and dynamic pages

那年仲夏 提交于 2020-01-24 22:18:04

问题


I have created website using the CI framework 3.0 and still i am stuck in creating the xml sitemap for static and dynamic pages.


回答1:


Your question is very clear. i'm using codeigniter with the sitemap php Library. Its awesome and has clear directions: https://github.com/evert/sitemap-php

To get you started - Put the SitemapPHP folder in application/libraries

Then, in your controller, in your method you call the library like:

  public function makeSitemap()
{

        // APPPATH will automatically figure out the correct path
        include APPPATH.'libraries/SitemapPHP/Sitemap.php';

        // your website url
        $sitemap = new Sitemap('http://yourwebsite.com');

        // This will also need to be set by you. 
        // the full server path to the sitemap folder 
        $sitemap->setPath('/home/username/public_html/sitemap/');

        // the name of the file that is being written to
        $sitemap->setFilename('mysitemap');

        // etc etc etc 

}


来源:https://stackoverflow.com/questions/40624981/how-to-create-sitemap-for-static-and-dynamic-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!