如何为静态和动态页面创建站点地图 [英] How to create sitemap for static and dynamic pages

查看:79
本文介绍了如何为静态和动态页面创建站点地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用CI框架3.0创建了网站,但仍然停留在为静态和动态页面创建xml网站地图中。

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.

推荐答案

您的问题很明确。我正在将codeigniter与站点地图php库一起使用。它的功能强大并且有明确的指导: https://github.com/evert/sitemap-php

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

入门-将SitemapPHP文件夹放在应用程序/库中

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 

}

这篇关于如何为静态和动态页面创建站点地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆