简体   繁体   中英

get codeigniter page output and place it on non-codeigniter site

Hey guys was hoping you could help me out.

I am working on a site that essentially has two parts, one in codeigniter and one in non-codeigniter(ie in magento).

I know this is a bad idea to begin with, but too late now.

Now thing is, I need a particular page's output AS-IS from the codeigniter site on the other site (the page is basically a search page). And I need this to be a backend solution for SEO so iframe wont do.

Both sites are hosted on the same domain.

I considered using CURL library to get the output of that page (after sending it post or get) and display it, but I am guessing that would be very inefficient.

Is there any other way? Thanks in advance.

A better way would be get page answer in xml, json and "draw" it in Magento. But as far as I understand you can't, so your chance would be retrieve page through cURL call or through buffering output , you should make some benchmark to compare two ways.

You could do Cross-Domain Ajax using jQuery JSONP. jQuery JSON Docs

You could also do on the other page

<?php echo file_get_contents("http://...yoururl..."); ?>

file_get_contents docs

Something Else Useful perhaps ob_start()

Example in Controller:

function search() {
  ob_start();
  /* Your Controller Code as normal */

  $saved_output = ob_get_clean();
  /* Now you have output in a variable as-is and you can send it out */
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM