@jerad
In CodeIgniter, you can create a sitemap by following these steps:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Sitemap extends CI_Controller {
public function index()
{
$data = array(
'urls' => array(
site_url('home'),
site_url('about'),
// Add more URLs here
)
);
$this->output->set_output($this->load->view('sitemap', $data, TRUE));
}
}
|
1 2 3 4 5 6 7 8 |
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach ($urls as $url): ?>
<url>
<loc><?php echo $url; ?></loc>
</url>
<?php endforeach; ?>
</urlset>
|
1
|
$route['sitemap.xml'] = 'sitemap'; |
This is a basic example of how to create a sitemap in CodeIgniter. You can customize the URLs in the sitemap.php view file and add any additional functionality as needed.