The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> CSS Help
|
css, functions, headers and includes troubles
Discuss css, functions, headers and includes troubles in the CSS Help forum on Dev Shed. css, functions, headers and includes troubles Cascading Style Sheets (CSS) forum discussing all levels of CSS, including CSS1, CSS2 and CSS Positioning. CSS provides a robust way of applying standardized design concepts to your web pages.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

July 20th, 2003, 02:32 PM
|
 |
echo $usertitle['computer'];
|
|
Join Date: Jan 2003
Location: UK
|
|
|
css, functions, headers and includes troubles
Hi,
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?
Thanks,
computer
|

July 20th, 2003, 02:38 PM
|
 |
mod_dev_shed
|
|
Join Date: Sep 2002
Location: Atlanta, GA
|
|
|
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
|
 |
echo $usertitle['computer'];
|
|
Join Date: Jan 2003
Location: UK
|
|
return text how?
some of the header needie fucntions build the cell headers and stuff:
for example:
PHP Code:
function mainbox_top(){
?>
<table width="100%">
<tr>
<td>
<table cellspacing="0" cellpadding="0" width="100%">
<tr>
<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>
</tr>
<tr>
<td background="images/box/M-left.gif"><img src="images/box/M-left.gif" width="15" height="15" /></td>
<td>
<!-- Content -->
<table width=100% BGCOLOR="white">
<tr>
<td>
<p>
<?php
}
?>
|

July 20th, 2003, 02:40 PM
|
|
The Freshmaker
|
|
Join Date: Jul 2003
Location: Smurf Village
Posts: 335
Time spent in forums: 3 Days 21 h 38 m 32 sec
Reputation Power: 0
|
|
Quote: | 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. |
why would some of your functions cause error if the css was included?
|

July 20th, 2003, 02:41 PM
|
 |
echo $usertitle['computer'];
|
|
Join Date: Jan 2003
Location: UK
|
|
because to include the css i must do a <head>, no?
as soon as that happens kabloom 
|

July 20th, 2003, 02:47 PM
|
|
The Freshmaker
|
|
Join Date: Jul 2003
Location: Smurf Village
Posts: 335
Time spent in forums: 3 Days 21 h 38 m 32 sec
Reputation Power: 0
|
|
|
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
|
 |
mod_dev_shed
|
|
Join Date: Sep 2002
Location: Atlanta, GA
|
|
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):
PHP Code:
function foo()
{
$foo = 'text to return';
return $foo; // could just `return 'text to return';`
}
// use
echo foo();
// or
$foo = foo(); // stores in variable for later
|

July 20th, 2003, 03:00 PM
|
 |
echo $usertitle['computer'];
|
|
Join Date: Jan 2003
Location: UK
|
|
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") ?>
common.php:
Code:
<?php
session_start();
header("Cache-control: private");
include("configuration.php");
include("lib.php");
db_connect($dbhost, $dbuser, $dbpass, $dbdb);
include("online_update.php");
?>
configuration and online_update self explainatery. db_connect is a fnction defiend in lib.php
header.php:
does all the sites <head> and starts the body. also includes the css line.
menu.php:
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,
speak later,
computer
|

July 20th, 2003, 06:42 PM
|
 |
Contributing User
|
|
Join Date: Dec 2002
Location: Barcelona
Posts: 133
Time spent in forums: < 1 sec
Reputation Power: 11
|
|
|
why dont you use templates? smarty, for instance.
|

July 20th, 2003, 06:54 PM
|
|
The Freshmaker
|
|
Join Date: Jul 2003
Location: Smurf Village
Posts: 335
Time spent in forums: 3 Days 21 h 38 m 32 sec
Reputation Power: 0
|
|
Quote: | i have a lib.php which contains some functions that cannot be called after headers have been sent. |
... 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.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|