ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Very fast sitemap generator (library and helper)

January 29, 2012 3:23pm

Subscribe [5]
  • #1 / Jan 29, 2012 3:23pm

    Patroklo

    18 posts

    First of all, if you can’t understand something in the text, please tell me and I’ll try to make myself clearer. English it’s not my language and I usually don’t have any chance for practicing it.

    Last week I needed a sitemap generator for my personal project website. It’s a webcomic hosting made fully in codeigniter that uses a subdomain for each webcomic. This is a very particular neccesity because I must make a different sitemap file for each subdomain and I have a tons of urls that change a lot to add to the sitemap files. In short, there are more than 2,000 different files and more than 150,000 different urls in total.

    I tried to use the sitemap generator that it’s posted in the codeigniter wiki but I didn’t liked very much its performance, so I decided to make my own generator and now its posted in git hub for everyone that could need a faster sitemap generator.

    Also, as addition, it also can be used to make normal xml files.

    Every comment, criticism or anything you want to say(even only say “hello there!”) it’s very welcome.

    (I also have a point I’d like to check… is there any possibility to upload this code to the codeigniter wiki?)

    Thanks!

    GIT HUB PROJECT URL: https://github.com/Patroklo/Codeigniter-sitemap-creator

  • #2 / Jan 31, 2012 1:06am

    CI705

    3 posts

    it looks great, but are there any instructions for beginners like me, thanks

  • #3 / Jan 31, 2012 10:16pm

    Clooner

    464 posts

    Looking for a good sitemap generator at the moment! Does it also generate relevant lastmod, changefreq, & priority reports?

  • #4 / Feb 01, 2012 2:44am

    Patroklo

    18 posts

    it looks great, but are there any instructions for beginners like me, thanks

    I’ll try to make today one more complicated example an a simple tutorial. Thanks!

    Looking for a good sitemap generator at the moment! Does it also generate relevant lastmod, changefreq, & priority reports?

    In theory you can use any label you want in the generator, you only have to make it.

  • #5 / Feb 05, 2012 1:48pm

    Patroklo

    18 posts

    I have just uploaded a new version of the code, it’s a little slowlier(like one more second from the 44 initial seconds) but I think it works better and also let’s to add data into the sitemap and not only making one from scratch.

    I have also posted a new example in wich you can also make a sitemap index and a sitemap that has image urls, a tag that google accepts. The sitemap builder can work with every special tag that google accepts: video, images, code, etc…

    Also I have made a little manual in spanish and english just for helpping you working with the library and models. If you have any problem or question, feel free to ask. Thanks!!!

  • #6 / Mar 12, 2012 1:27pm

    tdupp

    2 posts

    To the creator of this code, I’m in need of a lot of help.

    I’m attempting to add this to our website, unfortunately I’m not strong in PHP coding, and I’m getting an error in the controller.

    function index()
     {
      echo ('hi');
      $this->load->model('sitemaper_model');
      //$this->sitemaper_model->makeSitemapBlock('imagesList');
      //$this->sitemaper_model->makeSitemapBlock('blogList');
      $test=$this->sitemaper_model->makeSitemapBlock('sitemap_builder');
      echo ($test); 
     }

    in an attempt to debug I’ve shown my code here, when i go to theurl/sitemap

    it echo’s the hi, but it does not echo the $test.

    I’m trying to determine where the break is occcuring.

  • #7 / Mar 12, 2012 7:22pm

    CroNiX

    4713 posts

    You can’t echo a boolean value (TRUE/FALSE), which is what sitemaper_model::makeSitemapBlock() returns.
    Try var_dump($test) instead.

  • #8 / Mar 13, 2012 9:26am

    tdupp

    2 posts

    You can’t echo a boolean value (TRUE/FALSE), which is what sitemaper_model::makeSitemapBlock() returns.
    Try var_dump($test) instead.

    okay the result was “bool(false)” when going to theurl.com/sitemap

    Here is the model

    <?php
    class sitemaper_model extends CI_Model {
    
      private $block;
    
      function sitemaper_model() {
      
        // Call the Model constructor
        parent::__construct();
       $this->load->helper('sitemap_lists');
     $this->load->library('sitemaper_builder');
      } 
      
      function makeSitemapBlock($new_block, $datos = NULL)
      {  
        if(class_exists($new_block) and is_subclass_of($new_block, 'urlList'))
      {
         if($datos == NULL)
         {
          $this->block = new $new_block();
       }
       
    
       $this->sitemaper_builder->builder(array('archive' => $this->block->getFileName(), 'type' => $this->block->getType()));
       $this->generateSitemap();
       return TRUE;
      }
      else
      {
       return FALSE;
      }
      }
      
      function generateSitemap()
      {
    
        while($this->block->makeQuery())
      {
       $rowsList =& $this->block->getList();
    
       $this->sitemaper_builder->insertLines($rowsList);
      }
      
      $this->sitemaper_builder->close(true);
      }
      
       
     } 
    ?>

     

    Here the skinny:  This is what I need to get this code to do for me.

    1. generates the XML and prints it to sitemap.php
    2. I’m not allowed to save an xml file to the server or ping google - i need to disable these behaviors.
    3. The idea is that we will just manually take the xml generated from sitemap.php and upload manually.

     

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases