Jump to content


Photo

including HTML the hard way?


  • Please log in to reply
1 reply to this topic

#1 icowden

icowden
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 22 October 2006 - 11:35 PM

Hi all,

I have installed php-calendar 0.10.5 as a basic calendar. I know very little about PHP by the way. The index.php file defines various items and then includes 3 files:-

require_once($phpc_root_path . 'includes/calendar.php');
require_once($phpc_root_path . 'includes/setup.php');
require_once($phpc_root_path . 'includes/globals.php');

Within calendar.php there is a function to define the head of the document that will be output in setup.php.

function create_xhtml($rest)
{
global $config, $phpc_script;

$output = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n"
."\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
$html = tag('html', attributes('xml:lang="en"'),
tag('head',
tag('title', $config['calendar_title']),
tag('meta',
attributes('http-equiv="Content-Type"'
                                                .' content="text/html;'
                                                .' charset=iso-8859-1"')),
tag('link',
attributes('rel="stylesheet"'
.' type="text/css" href="'
.$phpc_script
.'?action=style"')),
'<!--[if IE]><link rel="stylesheet" '
.'type="text/css" href="all-ie.css" />'
.'<![endif]-->'),
tag('body',
tag('h1', $config['calendar_title']),
navbar(),
$rest,
link_bar()));

return $output . $html->toString();
}

Now rather than having to rather laboriously go through my whole site header which uses CSS, styles and 4 positioned layers, I wondered if there was an easier way to do this. I tried including the header part as an html file without closing tags (calendarpage.inc), but this generates an error once setup.php is reached, informing me that sessionstart() has a problem as the page has already begun.

Has anyone any ideas how I can rewrite the function above, or remove it and use an include to generate the header part of the php? I have attached the php files mentioned.

thanks very much for any help!

Iain

[attachment deleted by admin]

#2 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 23 October 2006 - 05:36 AM

You can use output buffering.. like this:

ob_start();
include('header.html');
$header = ob_get_clean();

I'm pretty sure that'll do what you want.  Then you have your HTML in a string.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users