<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class example_sitemap_api extends sitemap
{

    protected $module_name = 'example';

    public function __construct()
    {

        $this->get_static();
        $this->get_data();
    }

    protected function get_data()
    {

        //load instance
        $CI = & get_instance();

        //get data from db
        $db_data = $CI->db->
                        select('alias')->
                        where('active', TRUE)->
                        order_by('id_test', 'DESC')->
                        get('test')->result_array();

        // if module configurate then build sitemap data
        if (!empty($this->basepage['id'])) {
            foreach ($db_data as $item) {
                $this->map[] = new sitemap_item(base_url($this->basepage['alias'] . '/' . $item['alias']), date("Y-m-d"), $this->changefreq, $this->priority);
            }
        }
    }

}
