CodeCharge Studio
search Register Login  

Web Reports

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

YesSoftware Forums -> Archive -> CodeCharge.Discussion

 Example of how to get code charge pages into existing stuff

Print topic Send  topic

Author Message
Carsten Blau
Posted: 03/30/2001, 6:38 AM

Hello,

I had the problem, that the portal I'm working on already existed and
code charge pages should be easily included for some database
maintainances... All the stuff around the code charge elements has
dynamic parts, so the header & footer of codecharge pages was no
solution (static). The code of the generated code charge pages should
not be changed, to allow quick changes if needed.

Here's the trick, works with PHP4 + Templates and should also do in
JSP/ASP as long as output buffering is available:

- You need a script that is always executed before a page is called
(autoprepend in PHP, see PHP.INI)
- Start Output-Buffering, create the dynamic header, save the output
buffer as part-1, clean the buffer (without sending it to the client)
- Start Output-Buffering again, include the dynamic code charge stuff
(by executing it), save the output buffer as part-2, clean the buffer
(without sending it to the client); you must extract the stuff between
the <BODY>-tags to get rid of the second <HEAD> etc.
- Start Output-Buffering again, create the dynamic footer, save the
output buffer as part-3, clean the buffer (without sending it to the
client)
- Assemble the 3 parts, send it to the client as the final result

See the PHP4-code extract at the end of the message. Works fine for me
(you can't see it as it not yet live). With session vars I can feed the
codecharge pages with primary keys etc. from other pages as needed.

A problem could be, if the output is delayed very long, as the client
doesn't get any feedback until it's all done.

But: it looks cool, and is very very easy to maintain :-)


Carsten Blau
--
| Dipl.-Informatiker (FH) Carsten Blau eMail: cblau@it-beratung.de
| Freiberuflicher EDV-Berater Tel: +49 6858 60620


<?
// insert unchanged code charge pages into a dynamic(!), plain-HTML
framework
// (code charge only allows static HTML in footer/header sections)
// this is necassary as long as the <html> and <head>-Tags are still
in
// the called pages (otherwise autoprepend and autoappend of php will
work)
//
// this comes into the autoprepend file
// must be filled with "real life"
//
// cblau@it-beratung.de 03-2001
//

session_start(); // works only with cookies!
(CodeCharge-Bug)

// ------
// Part 1 - dynamic Header
// ------
ob_start (); // buffer output

$vTags1 = DynamicHeader(); // Do your complicated stuff here
echo $vTags1;

$vOutPart1 = ob_get_contents(); // save output buffer
ob_end_clean(); // clean output

// ------
// Part 2 - Include the code charge generated stuff
// ------
ob_start();
include ($DOCUMENT_ROOT . $PHP_SELF); // file called by browser
// include to execute

$vOutPart2 = ob_get_contents(); // save output buffer
ob_end_clean(); // clean output

$vOutPart2 = HtmlExtractBody($vOutPart2); // this must extract the
code between
// <BODY> and </BODY>
// use regular expressions
to achieve this

// ------
// Part 3 - dynamic Footer
// ------

ob_start();

$vTags3 = DynamicFooter(); // Do your complicated stuff here
echo $vTags3;

$vOutPart3 = ob_get_contents(); // save output buffer
ob_end_clean(); // clean output

// ------
// send to browser
// ------

$vOutput = $vOutPart1 . $vOutPart2 . $vOutPart3; // assemble output
echo $vOutput; // send to output buffer
flush(); // send to browser

// ------
// end the session
// ------

exit; // exit to prevent calling the
page again

?>

   


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.