CodeIgniter Forums
Exporting a CI site to static files - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Exporting a CI site to static files (/thread-25416.html)



Exporting a CI site to static files - El Forum - 12-11-2009

[eluser]The Hamburgler[/eluser]
Hello, we were asked to develop a static site for a clients intranet.
To speed things up I built it using codeigniter, I now need to turn the site into static html pages. OH NOES I hear you cry!

My initial idea was to use curl to call each unique url and save the returned HTML to a static file. The site is relatively simple, no dynamic parameters. there's about 8 controllers, one for each language, and each has the same 6 public methods (pages).

I could just define these in arrays and loop through them but I thought i'd see if there's a more flexible way. So I tried reading all the files in the sites controllers folder using get_filenames(), skipping 'index.html' and the exporter controller. I then tried to load an instance of each class so I could use get_class_methods to get an array of pages.

This is where I face the problem, PHP throws a Undefined property error as soon as it comes across a call to a library. I'm guessing this is because this skips the CI controller loading process. Does anyone have any suggestions for a way around this?


Exporting a CI site to static files - El Forum - 12-11-2009

[eluser]Jeroen Brussich[/eluser]
I have done something similar in the past.
The site wasn't built in CI though, but I think the same principal applies.

I used http://www.httrack.com/to download my site to static pages, then opened my HTML-editor to remove the 'downloaded by HTTrack' notice and to adjust the links...


Exporting a CI site to static files - El Forum - 12-11-2009

[eluser]Phil Sturgeon[/eluser]
Why not just use the Output cache? OR Squid proxy?


Exporting a CI site to static files - El Forum - 12-11-2009

[eluser]Colin Williams[/eluser]
WGET


Exporting a CI site to static files - El Forum - 12-11-2009

[eluser]The Hamburgler[/eluser]
Thanks, In the end I just defined an array of methods and saved the curl output of each to file.

I've used software similar to HTTrack before but I needed to change the site_url before outputting the files so I may have caused some problems.

I'd still be interested in finding a way to get a list of methods for each controller though. This could be used to auto generate a two tear navigation system.


Exporting a CI site to static files - El Forum - 12-11-2009

[eluser]n0xie[/eluser]
[quote author="The Hamburgler" date="1260552814"]I'd still be interested in finding a way to get a list of methods for each controller though. This could be used to auto generate a two tear navigation system.[/quote]

Have you tried get_class_methods ?

I would have used the caching library that CI has. It saves an output copy, which is what you want...


Exporting a CI site to static files - El Forum - 12-11-2009

[eluser]The Hamburgler[/eluser]
[quote author="n0xie" date="1260557543"][quote author="The Hamburgler" date="1260552814"]I'd still be interested in finding a way to get a list of methods for each controller though. This could be used to auto generate a two tear navigation system.[/quote]

Have you tried get_class_methods ?

I would have used the caching library that CI has. It saves an output copy, which is what you want...[/quote]

Yeah tried get_class_methods, but you can't use it on a controller from within another without throwing php errors.

I used the CI caching lib for another site but If my memory serves me it generates a random hash name for each file? This would mean i'd have to rename 50+ files.


Exporting a CI site to static files - El Forum - 12-11-2009

[eluser]n0xie[/eluser]
[quote author="The Hamburgler" date="1260557900"]
I used the CI caching lib for another site but If my memory serves me it generates a random hash name for each file? This would mean i'd have to rename 50+ files.[/quote]
Hmm good point. I kinda forgot about that ;-)