I’m using codeigniter as the framework for my website. However, I have the need to integrate content from an application built on a separate Tomcat server.
Is there a way I can keep serving up the template-based elements of navigation, banner images and codeigniter apps in the top of my content areas, while the body is delivered through Tomcat into the site’s lower content areas? I’m well aware that one can serve up a page fragment through a view, but could the content in the view come from my Tomcat app?
One possible approach is to have your CodeIgniter controller retreive the content behind the scenes through file_get_contents or maybe phpcurl.
Snippet inside CI controller:
Snippet from relevant_view.php:
Some caveats to consider:
(1) Is there any security on the Tomcat application server source pages (Basic Auth or explicit login page)?
(2) Any proxy or similar issues accessing the Tomcat application server?
(3) Is the PHP in question set up to retrieve from external sources and/or was it compiled cURL capabilities?
(4) Latency from the Tomcat side will impact the CodeIgniter side. Some of this can be mitigated with the Output Class caching from CodeIgniter if the source content is relatively static.
If there are large number of pages, the external content retrieval code can be factored out into a custom CodeIgniter library or helper and then loaded.