Jump to content

Dynamic StyleSheet - Is there a way to do this?


spacepoet

Recommended Posts

Hello:

 

I am trying to make a StyleSheet updateable from my admin panel, but I'm not sure if what I want to do is possible.

 

So ...

 

I have a TEXTAREA in my admin panel that writes to the DB just fine. it has styles like:

body 
{ 
margin: 5px 0;
padding: 0;
background-color: #ebe9e6;
background-image: url('../images/Site-BG2.jpg');
background-position: center bottom;
background-repeat: no-repeat;
background-attachment: scroll;

font-family: arial, sans-serif;
font-size: 100%;
line-height: 1.4em;
}
...
Etc...

 

On the frontend, it writes into the StyleSheet just fine like:

<?php
include('myConn.php'); //contains your mysql connection and table selection

$query=mysql_query("SELECT * FROM myStyleSheet") or die("Could not get data from db: ".mysql_error());

while($result=mysql_fetch_array($query))

{

  $myPageData=$result['myPageData'];

}

?>


<?php echo $myPageData; ?>

 

 

So, what I want to see is if I can somehow pull the styles onto the page like:

<link rel="stylesheet" type="text/css" href="include/StyleSheet.css" />

 

Now, if I do it as listed above it and look at the code it displays the

<?php
include('myConn.php'); //contains your mysql connection and table selection
Etc...

 

If I do it like

<link rel="stylesheet" type="text/css" href="include/StyleSheet.php" />

 

It displays the styles fine, but the browser doesn't read it as a StyleSheet and therefore the page doesn't get formatted.

 

So, is there any way to make this work? Anyone have any ideas about this?

 

The idea is so I can manage the Styles via an admin panel remotely without having to login with web editing software.

 

Thanks.

 

 

I am working on something similar and I added this line to my .htaccess file so that I could avoid using the .php extension and instead I was able to use the .css extention to avoid any possible search engine conflicts. I am not really sure that there would be any but was trying to be safe.

RewriteRule ^(.*)\.css$ $1\.php [L]

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.