Re: Including files with PEAR::IT

From: Date: Thu, 25 Apr 2002 08:04:48 +0000
Subject: Re: Including files with PEAR::IT
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-1267@lists.php.net to get a copy of this message
Am 25 Apr 2002 03:21:14 +0200 schrieb Eskil Kvalnes <eskil@uten.net>: > Hey, > > How can I include a file when using PEAR::IT without messing up the > template? > > I have one section of a site that needs to be included... You mean, you have an include file that produces some output which has to be included into a page that normally only uses a template for its output? If I understood this correctly, here´s how you can do this: - Put a placeholder in your template where the output of the included file should appear. - In the script that includes the file, write this: // Start output buffering ob_start(); // Include file, all output automatically goes into the buffer include("myIncludeFile.php"); // Write the output buffer into a variable $fileOutput = ob_get_content(); // Destroy the output buffer without sending the output to the browser ob_end_clean(); // Attach the output to a placeholder in your template $tpl->setVariable("theFileContentGoesHere", $fileOutput); I didn´t test this, so there might be syntax errors, but this is the principle how it´s done. Regards, Markus -- *21st Media* | Consulting, Konzeption, Produktion für die Bereiche: Markus Wolff | Internet, Intranet, eCommerce, Content Management, Hamburg,Germany | Softwareentwicklung, 3D-Animation, Videostreaming http://21st.de | Tel. [+49](0)40/6887949-0, Fax: [+49](0)40/6887949-1

« previous php.pear.general (#1267) next »