Closed Thread Icon

Topic awaiting preservation: php inside and css (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=26243" title="Pages that link to Topic awaiting preservation: php inside and css (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: php inside and css <span class="small">(Page 1 of 1)</span>\

 
CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 07-15-2005 03:50

Here is what I am trying to do:

Use the hide text with background image with CSS but have it dynamically pulled in using php.

Here is what I have:

Pages are called via php include (i.e. welcome, about us, contact us...)
In the index page I have a switch statment:

code:
switch ($_GET['link']){
	case 'contact':
		$page = "pages/contact.php";		
		$masthead_title="Contact";
     	        $masthead_image"../images/contact_header.gif";
		break;
	
	case 'about':
	     $page ="pages/about.php";
	     $masthead_title="About Us";
	     $masthead_image"../images/about_header.gif";
	     break;	
	
		 		 		    
	default:
	     $page ="pages/main.php";	     
	     $masthead_title="Welcome";
	     $masthead_image"../images/welcome_header.gif";
	     
}



Then in the main.php page I have this:

code:
<div id="masthead"><h1><span><? echo($masthead_title); ?></span></h1></div>



The external style sheet is a php page that has this:

code:
#masthead{
	height:55px;
	background-image:url(<?echo($masthead_image);?>);
	background-repeat:no-repeat;
	background-position: right;
	font: bold 18pt Georgia, "New Century Schoolbook", "Bitstream Vera Serif", Utopia, "Times New Roman", times, serif;
	text-decoration:underline;
	margin-bottom:20px;
	margin-right:10px;
}

#masthead h1{
	margin:0px;
	padding:0px;
}

#masthead h1 span {
	display:none;
}




For some reason It doesn't put the text in or anything. I have other images used as background images in the style sheet that are NOT dynamic and those are being pulled in just fine. It doesn't pull in the text either. Anyone see what I'm doing wrong?

Thanks in advance!

Later,

C:\



(Edited by CPrompt on 07-15-2005 03:51)

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 07-15-2005 06:50

you'll need to pass in $masthead_title in your <link ref> to your stylesheet.

The browser retrieves your stylesheet in a a seperate request - if you download it and look at it,
you'll find that it will contain an empty space (or an error message if php->error_reporting (E_ALL) was set)

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 07-15-2005 12:46

you mean like:

$masthead_title = "Welcome";
inside the index.php

and then for the link it would be
<link href="stylesheet.php?masthead_title=<?=$masthead_title;?>" rel="stylesheet" type="text/css"/>


I tried to put this in the stylesheet.php :

header('Content-Type: text/css');

but that didn't seem to work.

Thanks I'll give it a go.

Later,

C:\

« BackwardsOnwards »

Show Forum Drop Down Menu