CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 Integrate CC and Drupal

Print topic Send  topic

Author Message
marcel

Posts: 26
Posted: 01/07/2010, 12:59 PM

I have tried to integrate CodeCharge and Drupal. I wanted an easy and straigth-forward way to use CC, with no big changes or hacks and just the basic and robust generation of database-code. And then place it in the contex of a CMS, with its navigation, webpages, menus, etc. In this case Drupal (www.drupal.org), a very powerfull and extendable open source CMS. But the approach fits to any CMS. I use PHP just as Drupal does.

This is how I have done it, but it is not optimal and I am very interested in other and optimized solutions. The strategy is to include "external" CC-script into your Drupalsite (www.myDrupalsite.com/?q=myDrupalpage) by an include or by file_get_contents of the PHP-code of a CC-application. Simply set a Drupal-page in PHP-mode and include 'http://www.myCCsite.com/myCCpage.php'.

That is the easy part and a first result looks fine. But then CC behaves unwanted because the paths get messed up and parameters will not be passed correctly. When you hover a link you will see it combines the servername of your CMS (Drupal) and the path and filename of your CC-application. Thus getting not-working links.

The first thing is to install CC on the same server and in the same directory as Drupal. Not nice, because directories are mixed and new updates must be carefully installed. And there might be duplicated filenames or directories. I could not find a way to install CC in a subdirectory and getting the correct links or other paths. I changed RelativePath and FileName, but no succes. Must be done better, but for now it works.

Then I made some script on the Drupal page and an include page in CC called redirectdata.php. Every page in CC gets this include as header. It has no HTML, but only custom code in the before show event. Redirectdata.php is a switch. If its get cms<>1 it builts and redirects to the correct DrupalCMS-URL and that file will ask (by file_get_contents and cms=1) for the pure dataresult of the CC-application.

Drupal works standard with a parameter q, e.g q=node/30 to address a page. I used an alias, q=ccdata. It makes its more difficult because it is not part of the URL-path but of the URL-parameters. But is works.

Now I can call a page www.myDrupalsite.com?q=ccdata&ccp=orderlist to get a nice datalist (from CC) into my Drupal-context.

Here are the scripts. On the Drupal site, in the page "ccdata":
------------------------------------
<?php
// Get content from within Drupal from an external CodeCharge-application
// Get the name of the server

$protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
$servername = $_SERVER['SERVER_NAME'];
$URL = $protocol.'://'.$servername;

// Get all paramaters
$parameters = $_SERVER['QUERY_STRING'];

// Get the parameter with the name of the CC-application
// Use the parameter ccp and provide it with the .php extension
// if ccp is not set, use a dummy (empty.php)
$ccp = $_GET['ccp'];
if ($ccp == '')
{$ccp = 'empty.php';}
else
{$ccp = $ccp.'.php';
}

// Build the URL with the right parameters as CC wants them and with cms=1
$URLparameters = $URL.'/'.$ccp.'?'.$parameters.'&cms=1';

// Fill a variable with the contents of the URL+parameters
$data = file_get_contents($URLparameters);

// Set the parameter cms to 0, by search and replace
// Strange, I could not succeed in getting it on a different value or to delete it, something to improve
$data = str_replace('cms=1', 'cms=0',$data);
echo $data;

?>

END------------------------------------


And on the CC-site, in the before-show-event of the includepage redirectdata.php:

BEGIN----------------------------------
// redirect to the correct URL, the one of the requesting CMS

// Name of the requested program or script, remove the leading slash and the .php
$CCscriptname = $_SERVER['SCRIPT_NAME'];
$CCccp = substr($CCscriptname,1);
$CCccp = rtrim($CCccp,".php");

//Name of the server NOTE: the same as Drupal, must be improved!
$CMSservername = $_SERVER['SERVER_NAME'];

// Get the value of the cms parameter
// 1 means a request from the CMS, just deliver flat data
// 0 or other value means translate the URL to the syntax of the requesting CMS, so it fits into the style of the CMS

$cms = CCGetFromGet('cms', 0);

if ($cms != 1)
// no request from the CMS to include content, so build the right CMSurl and redirect to it
// add or replace the parameters ccp and ccdata
{
$CMSquerystring = $_SERVER['QUERY_STRING'];
$CMSquerystring = CCAddParam($CMSquerystring,"ccp", $CCccp);
$CMSquerystring = CCAddParam($CMSquerystring,"q", "ccdata");
$CMSredirect = "http://".$CMSservername."?".$CMSquerystring;

header("Location: ".$CMSredirect);
exit;
}
END------------------------------------

Issues: install CC in subdirectory, not correct working PDF and print in Drupal, stylesheet
differences, authorization (can be done by cookies).

View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.