[prev in list] [next in list] [prev in thread] [next in thread] 

List:       smarty-general
Subject:    [SMARTY] Globally loading arrays: Best practice?
From:       Patrick Ben Koetter <p () state-of-mind ! de>
Date:       2005-12-28 10:10:09
Message-ID: 20051228101009.GD19649 () state-of-mind ! de
[Download RAW message or body]

I've created an array to hold the structure for a website navigation.
Initially I would load this array via a "menu.inc" file in the PHP file that
calls the SMARTY template like this:

<?php
...
require('menu.inc');
...
?>

This however produces a sideeffect that sends IE into quirksmode - a newline
is added to the beginning of all output pages like this:

--- begin ---

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" \
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html \
xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> <head>
  <title>Testpage</title>
</head>
<body>
<div class="navigation">

</div>
</body>
</html>
--- end ---

To verify the "require('menu.inc');" causes the problem, I've included the
contents of "menu.inc" into my "test.php" file and bingo! the newline at the
beginning of the output is gone.

Now I am looking for a convenient way to do this globally. I thought of doing
this with {config_load file="menu.conf"}, but I am not sure what syntax to use
if I want to add an array as variable.

Reading the docs I guess I should use "triple quotes (""")", but I thought I'd
ask here first, before I spend a few hours on something that cannot be done
the way I think or might be done in a much better way.

Any tipps or hints?

TIA,

p@rick

-- 
state of mind
Agentur für Kommunikation und Design

Patrick Koetter            Tel: 089 45227227
Echinger Strasse 3         Fax: 089 45227226
85386 Eching               Web: http://www.state-of-mind.de

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic