hi there,

trying to make themed website. seenthis in one shop. and i want to do the same.
i came across the problem wich i cant solve.

allow me first to paste the code, than wil ask the question.

css code

This templates containds the following static collors :
000000; ffffff; 081975; 09247D; 35242e; 432e3c; 523847; 868686;
990000; 9f7793; E5E5E5; EFEFEF; F8F8F8; e87400;
$scheme array contains dynamical colors and images
$images='true' if the template is using images
$TemplateSize<>0 swiches between width=100% and 789px
******************************************************************************/

/***************** DYNAMIC DECLARATION ******************/
header('Content-type: text/css');
$TemplateSize=($_GET['TemplateSize']>0 ? '100%' : '780px');
list($name,$LRmenu,$LRmenuS,$Ptitle,$Tmenu,$subnav,$LinksText,$LinksH,$images)=explode(":",$_GET['TemplateColors']);

/***************** IMAGES CSS ******************/
if($images) {
print <<<_CSS
 BODY {BACKGROUND-IMAGE: url(images/bg_${name}.gif); }
 .logobkg {BACKGROUND-IMAGE: url(images/top_${name}.jpg); }
 .vertmenutitle {BACKGROUND-IMAGE: url(images/top_${name}.jpg); }
 .bottom {BACKGROUND-IMAGE: url(images/top_${name}.jpg); }
 .entryTableHeader {BACKGROUND-IMAGE: url(images/top_${name}.jpg); }
 .entryTableHeader {BACKGROUND-IMAGE: url(images/top_${name}.jpg); }
_CSS;
}

now php code that does style switching !



/*****************************************************************************
                    SWITCH TEMPLATE SIZE & SCHEME
******************************************************************************/
if(!isset( $_SESSION["TemplateSize"])) { $_SESSION["TemplateSize"]=1; }
if(isset($_POST['TemplateSize']))      { $_SESSION["TemplateSize"]=-$_SESSION["TemplateSize"]; }

if(!isset($_SESSION["Template"])) { $_SESSION["Template"]='Blue'; }
if(isset($_POST['Template']))     { $_SESSION["Template"]=$_POST["Template"]; }

/*** $scheme=array($name,   $LRmenu, $LRmenuS,$Ptitle, $Tmenu,  $subnav, $LinksText,$LinksH,$images) **/
//$scheme=array($name,$LRmenu,$LRmenuS,$Ptitle,$Tmenu,$subnav,$LinksText,$LinksH,$images);
switch ($_SESSION["Template"]) {
 case 'Blue':
   $scheme = array('blue' ,'FF9933','F37B03','1A46A9','7D92C3','081C5E','000000','ff0000','true' );
  break;
 case 'DarkGreen':
   $scheme = array('green','00CC66','06B379','006633','3C9373','001708','000000','ff0000','true'  );
  break;
 default:
   $scheme = array('blue','FF9933','F37B03','1A46A9','7D92C3','081C5E','000000','ff0000','true' );
  break;}
$TemplateColors=implode(":",$scheme);

i my main index file i have this code to execute the css !


<link rel="stylesheet" type="text/css"  href="templates/'.$storeConfig['template'].'/shop.css?TemplateColors='.$TemplateColors.'&amp;TemplateSize='.$_SESSION["TemplateSize"].'">


Problem is when i change the theme, i doesnt recognise the varibles in css file.

Example. part of css code

  .vertmenutitle {BACKGROUND-IMAGE: url(images/top_${name}.jpg); }

as soon as i choose color for the website, ( lets say blue ) it should execute this varible called $name like this

  .vertmenutitle {BACKGROUND-IMAGE: url(images/top_blue.jpg); }

Can anyone help with this, i will be very much gratefull.
Thank you in advance, and sorry to troublem you reading my bad english.

    There is an easier way to do this:

    • Create as many different style sheets as you want.
    • Upload them.
    • Create a page (or section of the page) with links to switch themes
    • then...

    ----javascript version-----
    - make sure that all the style sheets are linked in the head section of yor document: 1main, the rest as "alternate" stylesheets.

    • when the links are clicked create a cookie and use appropriate stylesheet based on cookie

    -----PHP version -----
    - have the links to switch the style/theme go to a page with a get value
    example:

    <a href="http://site.com/styleswitcher.php?theme=1">theme one</a>
    <a href="http://site.com/styleswitcher.php?theme=2">theme two</a>
    etc...

    • based on the get value, create a cookie and send the user back to where they came

    • on each page check for theme cookie. if it exist, using a switch statement, supply the correct stylesheet in the head section.

    A good article exists here: http://www.alistapart.com/articles/phpswitch/

    Hope that helps.

      Write a Reply...