PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.smarty.general > Globally loading arrays: Best practice?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Globally loading arrays: Best practice?

Réponse
 
LinkBack Outils de la discussion
Vieux 28/12/2005, 11h10   #1
Patrick Ben Koetter
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Globally loading arrays: Best practice?

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
  Réponse avec citation
Vieux 28/12/2005, 14h24   #2
Pedro
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Globally loading arrays: Best practice?

There is probably some white space before or after the php tags in the
..php script or the template

Pete

Patrick Ben Koetter wrote:
> 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
>

  Réponse avec citation
Vieux 28/12/2005, 15h11   #3
Patrick Ben Koetter
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Re: Globally loading arrays: Best practice?

* Pedro <daffodil@daffodil.uk.com>:
> There is probably some white space before or after the php tags in the
> .php script or the template


That's what I had thought at first too and I spent an hour double-checking the
files. And yes, I found whitespace after one php tag, but that's it. I
couldn't find anything else.

Any other ideas?

p@rick



>
> Pete
>
> Patrick Ben Koetter wrote:
> >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
> >

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


--
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
  Réponse avec citation
Vieux 28/12/2005, 15h17   #4
Patrick Ben Koetter
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut solved: Re: [SMARTY] Re: Globally loading arrays: Best practice?

* Patrick Ben Koetter <p@state-of-mind.de>:
> * Pedro <daffodil@daffodil.uk.com>:
> > There is probably some white space before or after the php tags in the
> > .php script or the template

>
> That's what I had thought at first too and I spent an hour double-checking the
> files. And yes, I found whitespace after one php tag, but that's it. I
> couldn't find anything else.


Sometimes when you think you've checked everything it pays to do it again.
Yes, there was one more whitespace and after deleting it the error's gone.

Thanks!

p@rick




>
> Any other ideas?
>
> p@rick
>
>
>
> >
> > Pete
> >
> > Patrick Ben Koetter wrote:
> > >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
> > >

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

>
> --
> 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
>


--
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
  Réponse avec citation
Vieux 28/12/2005, 15h38   #5
messju mohr
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] solved: Re: [SMARTY] Re: Globally loading arrays: Best practice?

On Wed, Dec 28, 2005 at 03:17:47PM +0100, Patrick Ben Koetter wrote:
> * Patrick Ben Koetter <p@state-of-mind.de>:
> > * Pedro <daffodil@daffodil.uk.com>:
> > > There is probably some white space before or after the php tags in the
> > > .php script or the template

> >
> > That's what I had thought at first too and I spent an hour double-checking the
> > files. And yes, I found whitespace after one php tag, but that's it. I
> > couldn't find anything else.

>
> Sometimes when you think you've checked everything it pays to do it again.
> Yes, there was one more whitespace and after deleting it the error's gone.
>
> Thanks!


just a tip for the next time: turn off output-buffering and put out
some header() right before $smarty->display(). a more recent php will
throw an error like:

E_WARNING: Cannot modify header information - headers already sent by
(output started at ...:nn) in ... line nn

so the error message will contain the precise location of the
errornous whitespace

greetings
messju

> p@rick
>
>
>
>
> >
> > Any other ideas?
> >
> > p@rick
> >
> >
> >
> > >
> > > Pete
> > >
> > > Patrick Ben Koetter wrote:
> > > >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
> > > >
> > >
> > > --
> > > Smarty General Mailing List (http://smarty.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >

> >
> > --
> > 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
> >

>
> --
> 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

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h54.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,19869 seconds with 13 queries