Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom Theme Styles Issue - using style.php
#6
Thanks for the attempt n00dles101 your way worked, but it loads all the css content right in the head aka <style> </style> by a simple include, I can do the same thing just having the styles in header.php. But my agenda was to keep all styles external and not inline on the page. I wish I could make this work the way GETSIMPLE has it in admin "admin/template/style.php".

I have tried all humanly possible tricks to define and re-read the contents again into the page from style.php rendered as a css page with the header and just referenced in my original post, but that is not working.

The variables are globally defined as you can see in my original post so I don't know why they do not work in style.php rendered as a css page. I know this is my last attempt at this and many thanks for trying, but do you or anyone know how to recreate the exact same thing done by GETSIMPLE in the "admin/template/style.php" but for "theme/mytheme/style.php" and when link via CSS external on "theme/mytheme/header.php" it reads variables and posts their values from the xml.

A sample working code will be awesome to post here so I can read it.

Just like my original post but here is a copy of the codes again:

-----------------------------theme/mytheme/header.php-----------------------------------

<link rel="stylesheet" type="text/css" media="screen" href="<?php get_theme_url(); ?>/style.php">

----------------------------------------------------------------------------------------------------

------------------------------theme/mytheme/style.php-------------------------------------
<?php
header("Content-type: text/css");

function getXML($file) {
$xml = file_get_contents($file);
$data = simplexml_load_string($xml, 'SimpleXMLExtended', LIBXML_NOCDATA);
return $data;
}
$v = getXML(GSDATAOTHERPATH.'ThemeSettings.xml');
$customvariable1 = $v->themevariable1;
$customvariable2 = $v->themevariable2;
$customvariable3 = $v->themevariable3;
$customvariable4 = $v->themevariable4;
?>

#customdiv {
background-color: #<?php echo $customvariable1; ?>;
}

----------------------------------------------------------------------------------------------------

All the same thanks for showing me another PHP technique I did not know till now. I am always looking to expand my knowledge on the language.


n00dles101 Wrote:Doing it like this, as in your original post and how GS backend does it

Code:
<link rel="stylesheet" type="text/css" media="screen" href="<?php get_theme_url(); ?>/style.php">

renders the stylesheet and uses the variables internally and will not be available to other scripts.

So you have a choice of doing it the way GS does it and render the stylesheet with your variables.
Then you could read in the file again in your template to retrieve the variables for your theme.

or

Do it this way and have your stylesheet inline but your variables available to the template/theme.

Hope it helps...
Mike.
Reply


Messages In This Thread
Custom Theme Styles Issue - using style.php - by Chris&Kristi - 2012-01-28, 00:50:09



Users browsing this thread: 1 Guest(s)