Re: How to use frames with HTML/Page package ?
| From: | Klaus Guenther | Date: | Wed, 28 Jan 2004 16:52:07 +0000 |
| Subject: | Re: How to use frames with HTML/Page package ? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-10407@lists.php.net to get a copy of this message | ||
jeancharlesg@free.fr wrote:
> Hello,
> here there is my little (stupid) pb :
> I just want to generate this following XHTML sequence with the PEAR/Html
> suite.
Hi,
Unfortunately, though I have included the doctype declaration, it is
impossible to do that. :-/ I did not consider the fact that framesets have
the following element entry in the DTD[1]:
<!ELEMENT html (head, frameset)>
The way it is currently set up, the body element is always a direct child of
the html node.
I'll get to it hopefully sometime soon. Right now, I'm quite pressed for
time.
The easiest way I see would be to create a frameset class that you can
modify, add framesets to, etc. as a subclass and then putting body into the
<noframes> section.
I have attached a custom extended class. It's a quick and dirty hack, so I
cannot guarantee anything. Use at your own risk :-)
To use it, include the file and create and instance of myHtmlPage and set the
doctype to one of the frameset doctypes (e.g., XHTML 1.0 Frameset). Set the
->frameset property to include the frameset stuff. The body will
automatically be included in <noframes></noframes>, so don't try to include
that in the frameset property.
I'll work on integrating something like this to the main class. Until then,
this extension should work.
Hope this helps,
Klaus
[1] http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Frameset
<?php require_once 'HTML/Page.php'; class myHtmlPage extends HTML_Page { var frameset = ''; function toHtml() { // get line endings $lnEnd = $this->_getLineEnd(); // get the doctype declaration $strDoctype = $this->_getDoctype(); // This determines how the doctype is declared if ($this->_simple) { $strHtml = '<html>' . $lnEnd; } elseif ($this->_doctype['type'] == 'xhtml') { // get the namespace if not already set if (!$this->_namespace){ $this->_namespace = $this->_getNamespace(); } $strHtml = $strDoctype . $lnEnd; $strHtml .= '<html xmlns="' . $this->_namespace . '" xml:lang="' . $this->_language . '">' . $lnEnd; // check whether the XML prolog should be prepended if ($this->_xmlProlog){ $strHtml = '<?xml version="1.0" encoding="' . $this->_charset . '"?>' . $lnEnd . $strHtml; } } else { $strHtml = $strDoctype . $lnEnd; $strHtml .= '<html>' . $lnEnd; } $strHtml .= $this->_generateHead(); if ($this->_doctype['variant'] == 'frameset') { $strHtml .= $this->frameset. $lnEnd; $strHtml .= '<noframes>'.$lnEnd; $strHtml .= $this->_generateBody(); $strHtml .= '</noframes>'.$lnEnd; } else { $strHtml .= $this->_generateBody(); } $strHtml .= '</html>'; return $strHtml; } // end func toHtml } ?>
<?php require_once 'HTML/Page.php'; class myHtmlPage extends HTML_Page { var frameset = ''; function toHtml() { // get line endings $lnEnd = $this->_getLineEnd(); // get the doctype declaration $strDoctype = $this->_getDoctype(); // This determines how the doctype is declared if ($this->_simple) { $strHtml = '<html>' . $lnEnd; } elseif ($this->_doctype['type'] == 'xhtml') { // get the namespace if not already set if (!$this->_namespace){ $this->_namespace = $this->_getNamespace(); } $strHtml = $strDoctype . $lnEnd; $strHtml .= '<html xmlns="' . $this->_namespace . '" xml:lang="' . $this->_language . '">' . $lnEnd; // check whether the XML prolog should be prepended if ($this->_xmlProlog){ $strHtml = '<?xml version="1.0" encoding="' . $this->_charset . '"?>' . $lnEnd . $strHtml; } } else { $strHtml = $strDoctype . $lnEnd; $strHtml .= '<html>' . $lnEnd; } $strHtml .= $this->_generateHead(); if ($this->_doctype['variant'] == 'frameset') { $strHtml .= $this->frameset. $lnEnd; $strHtml .= '<noframes>'.$lnEnd; $strHtml .= $this->_generateBody(); $strHtml .= '</noframes>'.$lnEnd; } else { $strHtml .= $this->_generateBody(); } $strHtml .= '</html>'; return $strHtml; } // end func toHtml } ?>