i want to be able to inject a module, such as an iframe... but i dont want to go with iframes. is this possible to do?
if so, can some one guide me in the right direction?
like, almost as if i could include a page/.php file
php content injection
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: php content injection
Good guess. You can do:wkphilip wrote:like, almost as if i could include a page/.php file
Code: Select all
include 'mypage.php';http://us3.php.net/manual/en/function.include.php
(#10850)
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: php content injection
Use a template engine like Smarty or the following lightweight implementation:
Then you define the template like so:
And you would use them both like so:
HTH
Cheers,
Alex
Code: Select all
<?php
class Template{
function execute($path)
{
ob_start();
include($path);
$buff = ob_get_contents();
ob_end_clean();
}
}
Code: Select all
<html> <head> <title><?php echo $this->title; ?></title> </head> <body> <?php echo $this->content; ?> </body></html>Code: Select all
$template = new Template();
$template->title = 'Use this title pulled from a database or something?';
$template->content = 'Here is the content with <strong>HTML</strong> also pulled from a database or file?';
echo $template->execute('path/to/your/template.php');Cheers,
Alex