July 20th, 2003, 02:32 PM
css, functions, headers and includes troubles
I have setup a templating system for a project I am working on.
I have got a css file (css/style.css), which needs to be included before ANY text is sent to the browser.
A common.php which must NOT output anything to the browser (called before header functions and stuff).
A lib.php, which contains some functions, some which output text and need the CSS and some that will error if the css is included.
How can I setup something so that when the lib.php is called, for some functions the css header is included and sometimes not?
July 20th, 2003, 02:38 PM
This is a hard one for us b/c we have no idea what's in each file. Sounds like you may need to rethink some logic!? Try changing the functions in lib.php to return text instead of echo()ing it.
July 20th, 2003, 02:40 PM
return text how?
some of the header needie fucntions build the cell headers and stuff:
<table cellspacing="0" cellpadding="0" width="100%">
<td><img src="images/box/M-up-left.gif" width="15" height="15" /></td>
<td background="images/box/M-up.gif" width="100%"><img src="images/box/M-up.gif" width="15" height="15" /></td>
<td><img src="images/box/M-up-right.gif" width="15" height="15" /></td>
<td background="images/box/M-left.gif"><img src="images/box/M-left.gif" width="15" height="15" /></td>
<!-- Content -->
<table width=100% BGCOLOR="white">
July 20th, 2003, 02:40 PM
why would some of your functions cause error if the css was included?
July 20th, 2003, 02:41 PM
because to include the css i must do a <head>, no?
as soon as that happens kabloom
July 20th, 2003, 02:47 PM
when are you including lib.php before or after the css?
if before, why? sorry if I'm missing something :P
July 20th, 2003, 02:49 PM
I'm confused by it all as well. Why would you call a function that builds a table before you call a function that builds the <head>?
More on my previous post (returning text):
$foo = 'text to return';
return $foo; // could just `return 'text to return';`
$foo = foo(); // stores in variable for later
July 20th, 2003, 03:00 PM
okay i see i am not making sense
i have a lib.php which contains some functions that cannot be called after headers have been sent. some functions need to have the headers though before they will work correctly.
on the pages, i have:
<? include("common.php") ?>
<? include("header.php") ?>
<? include("menu.php") ?>
configuration and online_update self explainatery. db_connect is a fnction defiend in lib.php
db_connect($dbhost, $dbuser, $dbpass, $dbdb);
does all the sites <head> and starts the body. also includes the css line.
just the nav bar.
I hope you understand, if not, i can just post my source files for you to look at
Got to go soon though,
July 20th, 2003, 06:42 PM
why dont you use templates? smarty, for instance.
July 20th, 2003, 06:54 PM
... then don't call those functions after the header's been sent?
I'm still confused, does lib.php only declare functions or does it actually call/output something? If it only declares functions you should be OK.
It's valid to use CSS in a function, and to declare it before loading the CSS as long as the CSS has been loaded by the time you call the function.