I rewrote the code in functions. I'm sorry for I am a bit late in uploading. I've done the functions right after I posted the post above but it was late at night and didn't post it.
First we need the functions for updating the css values and the ini files.
There are 3 functions - with the first (CheckParams) we check the parameters set in joomla and compare them with these in the ini file.
The second function (UpdateCSS) updates the css file according to the sample file. If some changes have to be made in future with the dynamic css, this file has to be edited instead of style.css file (or whatever you have named it). If you don't the changes won't exist after the next settings change in admin panel as the style.css is being wholly rewritten.
The third function (UpdateINI) updates the ini file with the value returned by UpdateCSS.
Now - the code :
Code:
<?php
defined('_JEXEC') or die('Restricted access');
##############
if(!function_exists("CheckParams")):
function CheckParams($params=array(),$iniFile="css.ini",$prefix = "str_"){
if(!is_array($params)):echo "parameter 1 must be array!"; return false; endif;
if(!file_exists($iniFile)): echo "file in parameter 2 doesn't exist!"; return false; endif;
$check = $prefix.implode(",",$params);
$tocheck = file_get_contents($iniFile);
if(substr_count($tocheck,$check)!=0):return 1; else: return false; endif;
}
endif;
##############
if(!function_exists("UpdateCSS")):
function UpdateCSS($replacement,$replaceWith,$sampleFile="sample.css",$cssFileName="style.css"){
if(!file_exists($sampleFile)): echo "file in parameter 3 doesn't exist!"; return false; endif;
$tochock = file_get_contents($sampleFile);
$toprint_t = str_replace($replacement,$replaceWith,$tochock);
$fope = fopen($cssFileName,"w");
fwrite($fope,$toprint_t);
fclose($fope);
return implode(",",$replaceWith);
}
endif;
###############
if(!function_exists("UpdateINI")):
function UpdateINI($replaceWith,$iniFile="css.ini",$prefix="img"){
$checkstr = $prefix.$replaceWith;
if(!file_exists($iniFile)): echo "file in parameter 2 doesn't exist!"; return false; endif;
$fope = fopen($iniFile,"w");
fwrite($fope,$checkstr);
fclose($fope);
}
endif;
###############
?>
The second file is dynamiccss.php it is the file, which will be included to template's main section instead of cssupdate.php in the post above:
Code:
<?php
defined('_JEXEC') or die('Restricted access');
include_once("templates/".$this->template."/css/cssfunctions.php"); //including functions file
$updateCssParams = array($this->params->get("FieldOne"),$this->params->get("FieldTwo"),$this->params->get("FieldThree")); //getting params (must be array)
$updateCSS = CheckParams($updateCssParams,"templates/".$this->template."/css/css.ini","str"); //checking params in the ini file
##attribute 1 - params from the fields
##attribute 2 - the path to the ini file
##attribute 3 - prefix
if(!$updateCSS){ //checking are updates neccessary or not
echo "Currently updating CSS... \n\r";
$updatedCssParams = array("ReplaceMeWithColor","ReplaceMeWithWidth","ReplaceMeWithFloat"); //define replacement variables (must be array)
$asc = UpdateCSS($updatedCssParams,$updateCssParams,"templates/".$this->template."/css/sample.css","templates/".$this->template."/css/style.css");//updating the output css file
##attribute 1 - the variable strings, which have to be replaced
##attribute 2 - Replacement params
##attribute 3 - path to the sample css file
##attribute 4 - path to the output css file
UpdateINI($asc,"templates/".$this->template."/css/css.ini","str"); //Updating the ini file with new values
##attribute 1 - formated string returned by the update function
##attribute 2 - path to the ini file
##attribute 3 - prefix
echo "CSS updated! \n\r";
}
?>
The last file needed is the sample file, which doesn't differ the one above too much.
Code:
div{
background-color:#ReplaceMeWithColor;
float:ReplaceMeWithFloat;
width:ReplaceMeWithWidthpx;
}
There are another 2 files - the ini file and the outputed css file, but I won't add them as code because they are automatically created after the first execution of the code. However, they are included in the zip file below.
P.S. : Excuse my poor english, I know how annoying it is when a low - skilled newbie in coding or in english tries to do some lessons

. However I hope the code I wrote will be somehow helpful for your needs.