2011-03-12, 02:17 PM
I am going with file templates.
global.tpl contains this for testing
As you can see, every tag is on a new line, however when the template is echoed, this is what i get when i view the source:
I have no idea why it is like that. The file is saved as UTF-8 Without the Byte Order Mark with Notepad++. I should get what i have written, but it's displayed on one line
How do i get and echo the template? Very simple:
I found the problem. It is Notepad++ at fault here, though i don't know why. As soon as i opened it with regular Notepad, i saw that everything was on one line and so fixed it.
But why though? When i opened the edited file with Notepad++, everything was like
global.tpl contains this for testing
<html>
<body>
<head>
<title>test template</title>
</head>
{$contents}
</body>
</html>
As you can see, every tag is on a new line, however when the template is echoed, this is what i get when i view the source:
<html><body><head><title>test template</title></head>conteent</body></html>
I have no idea why it is like that. The file is saved as UTF-8 Without the Byte Order Mark with Notepad++. I should get what i have written, but it's displayed on one line
How do i get and echo the template? Very simple:
function echo_templates($template_name, $content)
{
$template = file_get_contents(ROOT."include/templates/global.tpl");
$echo_template = preg_replace("/".preg_quote('{$contents}')."/", $content, $template);
echo $echo_template";
}
I found the problem. It is Notepad++ at fault here, though i don't know why. As soon as i opened it with regular Notepad, i saw that everything was on one line and so fixed it.
But why though? When i opened the edited file with Notepad++, everything was like
<html>
<body>
<head>
<title>test template</title>
</head>
{$contents}
</body>
</html>