Is it possible to share data across two URLs

4 posts by 4 authors in: Forums > CMS Builder
Last Post: October 22, 2012   (RSS)

Hi Support
I was wondering whether it's possible to share data across two URLs, as almost all of the content is the same across the two sites, with only a different logo and different footer.

Otherwise, do you have any suggestions so my client doesn't need to maintain two separate sites?

Thanks

Re: [degreesnorth] Is it possible to share data across two URLs

Hi,

There are a few ways you can do this. If the sites are on the same server you could use one copy of CMS Builder. You would just have to ensure that the CMS Builder was installed at a path that both sites could access.

If the sites are on separate servers you could use PHP Curl do get the html data from one to another and display it:

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// grab URL and pass it to the browser
$html = curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);


The limitations here are that not all servers come with the Curl functions installed, and that getting dynamic data (for example submitting a form or sorting a list page) are made more difficult than normal.


The final method is to use Javascript, as some browsers don't support cross domain use of AJAX you could look into JSONP. You could create a dynamic javascript object that contains the page data one one site, then load it on the second and use Jquery to display it on the page. This post explains how it works:


http://stackoverflow.com/questions/2067472/please-explain-jsonp?answertab=active#tab-top


Thanks!
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Is it possible to share data across two URLs

By InHouse - October 22, 2012

FWIW, it may also depend a bit on your server config. We have one site that has two projects hosted on the same account. The hosting firm calls this an add-on slot but in practice the second site is a another directory under the root. All the site layout files are in there, but the CMS folder remains in it's original (and single) location.

Apart from that, the process was seamless and easy. The client now manages both "sites" from within a single instance of CMSB.

And yes, I checked with the good people at Interactive Tools before I did this to make sure they didn't object. They didn't. They're cool. ;-)

J.