CodeIgniter Forums

Full Version: How to create sitemap XML?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have the store based website I want to create sitemap XML but I didn't know how to create please help?
You can dynamically create an XML sitemap in CI through a cronjob executed function that builds the XML based on your specific content setup. Simply loop through the individual content tables and add the relevant data:

Set the orgins, then loop through the origin by getting that table from the DB then loop through the origin content to build the XML. Ideally for each orgin you build an extra XML and create a master sitemap.xml while you are at in case you exceed 50k pages.

Then just store the XML on the server (i.e. @file_put_contents('./sitemap.xml', $sitemap); and you are good.