Copy link to clipboard
Copied
I have an include file that contains a few functions that produce the necessary code for an html email. Since it makes tweaking the layout so much easier the include file contains mainly html code, e.g. (much simplified):
Include file:
<?php
function htmlmail($salutation)
{
ob_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html"; charset="iso-8859-1"></head>
<body>
<p>Dear <?php echo htmlentities($salutation); ?></p></body>
</html>
<?php return ob_get_clean();
}?>
I don't want DW CS4 to show this code in the design panel of the main file, since it displays incorrectly (thinks it has got to the end of the document, when of course it hasn't really even started.
Can anyone think of a tidy solution?
Ed
Copy link to clipboard
Copied
It's not clear to me how this page fits within your parent page, but...
An include file should only contain code fragments. It should not contain doctype declaration or html, head or body tags if those are already in the parent page.
Copy link to clipboard
Copied
As bregent says, an include should be only a code fragment.
However, if your function is intended to output a complete page, you could store the HTML output as a PHP string. To avoid lots of problems escaping quotes, you could use heredoc syntax.
Copy link to clipboard
Copied
Thanks David, I'm loving heredoc!
I did explain why I wanted html markup in the include (I am creating an html email body), and now that I am using heredoc it confuses DW just enough to be perfect (I could of course have used a PHP string, but it is visually a lot clearer to be able to see proper indentation on the screen, especially when debugging).
Ed