Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
No effect when I change CSS in style.php
  • Posted: 05.09.2004, 03:11
     
    robeano
    rank:
    Freshman Freshman
    registered:
     December 2003
    Status:
    offline
    last visit:
    15.05.05
    Posts:
    10
    I am working on a new theme. I upgraded to .750 (which went well, thank you very much), and I want to take advantage of the pnDefault theme. I made a copy of pnDefault and activated my new theme. When I change the templates via the Xanthia interface, I see the changes as soon as I submit them. When I change a template file (like master.htm) and click "Reload Template" that also works.

    I want to change CSS too, and from what I have read it's best to start with style.php. I have tried editing style.php in my new theme's directory (themes/mynewtheme/style/style.php) but nothing seems to change when I reload the page. I tried a similar change in pnDefault's style.php and those changes don't show up either. I tried changing style.css (themes/mynewtheme/style/style.css) but those changes don't show up either. Looks like I'm editing the wrong file?

    This makes me sad and confused. I'm sure everthing is fine with my PostNuke installation but I'm wondering if someone can point me in the right direction for making CSS changes to a pnDefault based theme?

    Here's some additional info from Xanthia configuration:
    Caching is not enabled.
    Xanthia does check for updated version of templates
    Xanthia does force templates recompilation
    Xanthia does store templates in database

    Please let me know if you need more info.

    Thanks, Robin
  • Posted: 05.09.2004, 07:23
     
    robeano
    rank:
    Freshman Freshman
    registered:
     December 2003
    Status:
    offline
    last visit:
    15.05.05
    Posts:
    10
    OK. I figured out that when I change palette colors it recreates the compiled CSS file located at:
    pnTemp/Xanthia_Config/mynewtheme.style.css. It seems that changes I make in style.php (themes/mynewtheme/style/style.php) now appear in mynewtheme.style.css. To update CSS, I should make a color palette change? Is there another way?
  • Posted: 05.09.2004, 12:55
     
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    online
    Posts:
    13418
    That is the configuration cache - it should be updated whenever the theme is loaded and the file has been changed...

    --
    Regards,
    Simon

    itbegins.co.uk - Zikula Consulting

    Please read the Support Guide
  • Posted: 07.09.2004, 03:31
     
    robeano
    rank:
    Freshman Freshman
    registered:
     December 2003
    Status:
    offline
    last visit:
    15.05.05
    Posts:
    10

    HammerHead

    That is the configuration cache - it should be updated whenever the theme is loaded and the file has been changed...


    So when is a theme loaded? Every time I refresh a page or click a link?
    Which file are you talking about when you say "...and the file has been changed"? style.php for my theme?
  • Posted: 07.09.2004, 14:52
     
    msandersen
    rank:
    Professional Professional
    registered:
     August 2002
    Status:
    offline
    last visit:
    25.11.05
    Posts:
    994
    I should think when you go in Xanthia Admin > Theme templates > Reload template which reloads and compiles the template from the file system into the database, or click Generate Configuration Cache from the theme config main menu
  • Posted: 09.09.2004, 00:24
     
    robeano
    rank:
    Freshman Freshman
    registered:
     December 2003
    Status:
    offline
    last visit:
    15.05.05
    Posts:
    10
    The configuration cache in my installation doesn't update when I change style.php. How do I fix it so the configuration gets updated?
  • Posted: 09.09.2004, 04:42
     
    robeano
    rank:
    Freshman Freshman
    registered:
     December 2003
    Status:
    offline
    last visit:
    15.05.05
    Posts:
    10
    I figured out part of the problem. This may be a bit obscure but someone down the road may run into this same issue, so I'll document what I've learned.

    What I finally realized today was that none of the CSS was being interpreted. At first, I was a bit confused (being new to making an XTE theme based on pnDefault). I read over the sticky post "XTE for Newbies" at least 10 times. I figured I must have been missing something. Sometimes I would make changes to a template or a palette and then it would like the CSS was also working but it wasn't.

    Today, I tried handcoding the link to the compiled CSS file (pnTemp/Xanthia_Config/mynewtheme.style.css) in the home.htm template. That still didn't work. Finally I tried to get the browser to look at the CSS file (actually putting mynewtheme.style.css in the URL) and I got a server error. I checked my error log (I use apache on a linux pc) and sure enough there was a problem:

    [Wed Sep 8 16:01:19 2004] [alert] /usr/local/httpd/htdocs/wmbdc/pnTemp/.htaccess: order not allowed here

    I often experiment with apache directives and I had restricted AllowOverrides for the Apache's document root. In httpd.conf I added Limit to the AllowOverride directive so that the .htaccess file with Order Allow and Deny directives would work correctly:

    Code

    <Directory "/usr/local/httpd/htdocs">
    AllowOverride AuthConfig Indexes FileInfo Limit


    The other possibility is to change AllowOverride to allow all:

    Code

    <Directory "/usr/local/httpd/htdocs">
    AllowOverride All


    Surprise! Surprise! The look of my new theme changed completely upon refreshing the Home page. So now I know for sure that CSS is being interpreted by the browser.

    The only way I can figure out how to recreate the final CSS file is to delete it from pnTemp/Xanthia_Config and then through the Xanthia interface go to the Color Palette, click Configure, then click "Submit these colors". Is there an easier way?
  • Posted: 09.09.2004, 19:46
     
    ioio
    rank:
    Freshman Freshman
    registered:
     September 2004
    Status:
    offline
    last visit:
    15.10.04
    Posts:
    12
    Hi,

    1st of all, forgive my english, I'm french.
    I'm also on PN .75
    To make style.php works, what u have to do is
    - not to have the theme u r working on activated
    - go to Xanthia "view themes"
    - make the changes u want in style.php
    - remove ur theme from Xanthia "view themes"
    - now it appears inactive
    - add ur theme
    - check urtheme.style.css that must have been updated.
    That's the way I proceed.

    Now, my problem is a var $text that has no value in my mytheme.style.css.
    I checked for it in xaninit.php this line:
    CreateThemeVar($skinID, 'size_text', _TM_SIZETEXT, '11', '');
    then in style.php (copy of the same file from pnDefault theme) this line doesn't work:
    ' font-size: '. "$text".'px;'."\n".
    so I changed it this way:
    ' font-size: '. $text.'px;'."\n".
    and this way:
    ' font-size: '. $size_text.'px;'."\n".
    and result in mytheme.style.css at this line is
    font-size:px
    => no px value
    and from Xanthia administration, theme setting, changes r not commited when changing values for this field while rcolwidth or lcolwidth changing values work.. 
    Anyone any idea ?
  • Posted: 15.09.2004, 20:40
     
    antz
    rank:
    Freshman Freshman
    registered:
     September 2004
    Status:
    offline
    last visit:
    22.09.04
    Posts:
    5
    Hi,

    forgive my english, I'm Czech.
    I'm also on PN .75

    I'Am make this modifications:

    style.php :

    Code

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

    //EDIT CSS FUNCTION VIA Xanthia (Added By AntZ - 15/09/2004)
    include 'style_cfg.php';

    echo "
    body {
    BACKGROUND: $background;
    font-family: Tahoma, Verdana, sans-serif;
    font-size: {$size_text}px;
    font-weight: normal;
    color: $text1;
    text-decoration: none;
    MARGIN-TOP: 0;
    MARGIN-LEFT: 0;
    MARGIN-RIGHT: 0;
    MARGIN-BOTTOM: 0;
    padding: 0;
    }
    hr {  color: $text2; height: 1px; width: 118px}..........


    style_cfg.php look like this :

    Code

    <?php
    $background = '#FFFFFF';
    $color1 = '#CEDFD3';
    $color2 = '#CEDFD3';
    $color3 = '#4FA695';
    $color4 = '#CEDFD3';
    $color5 = '#F1F9F3';
    $color6 = '#000000';
    $color7 = '#339999';
    $color8 = '#EFEFEF';
    $sepcolor = '#339999';
    $text1 = '#000000';
    $text2 = '#000000';
    $link = '#000000';
    $vlink = '#339999';
    $hover = '#EE752C';
    $iblkwidth = '145';
    $size_title = '12';
    $righton = '0';
    $indexcol = '1';
    $rcolwidth = '170';
    $lcolwidth = '140';
    $pagewidth = '100%';
    $size_text = '11';
    $size_litletext = '10';
    ?>
    and is generated by this function in theme.php :

    Code

    // Check we can load the xanthia api
    if (!pnModAPILoad('Xanthia', 'user')) {
        pnSessionSetVar('errormsg', _XA_APILOADFAILED);
    }

    if (!pnModAPILoad('Xanthia', 'admin')) {
        pnSessionSetVar('errormsg', _XA_APILOADFAILED);
    }

    // get the theme name from the file system
    $thename = basename(dirname(__file__));

    // set the theme path
    $themepath = 'themes/'.$thename;

    // set the image path
    $imagepath = $themepath.'/images';

    // we're a postnuke theme
    $postnuke_theme = true;

    // and a xanthia one too....
    $xanthia_theme = true;

    // get the theme id
    $skinID = pnModAPIFunc('Xanthia','user','getSkinID', array('skin' => $thename));

    // initialise the engine
    $engine = pnModAPIFunc('Xanthia','user','init');

    // check we have an engine object otherwise we can't procede
    if (!is_object($engine)) {
        echo _XA_FAILEDTOINITENGINE . $thename;
        exit;
    }

    echo $this->_tpl_vars['bgcolor'];

    // check which palette to use
    $paletteid = pnModGetVar('Xanthia',''.$thename.'use');

    // get the color scheme
    $colors = pnModAPIFunc('Xanthia','user','getSkinColors',
                array('skinid' => $skinID,
                'paletteid' => $paletteid));

    // get config
    $configs = pnModAPIFunc('Xanthia','admin','listConfig',
                array('skinid' => $skinID));

    // populate the color variables and defines
    if (!empty($colors)) {
        $bgcolor1   = $colors['background'];
        $bgcolor2   = $colors['color1'];
        $bgcolor3   = $colors['color2'];
        $bgcolor4   = $colors['color3'];
        $bgcolor5   = $colors['color4'];
        $bgcolor6   = $colors['color5'];
        $sepcolor   = $colors['sepcolor'];
        $textcolor1 = $colors['text1'];
        $textcolor2 = $colors['text2'];

        define('_XA_TBGCOLOR',''.$colors['background'].'');
        define('_XA_TCOLOR1',$colors['color1']);
        define('_XA_TCOLOR2',$colors['color2']);
        define('_XA_TCOLOR3',$colors['color3']);
        define('_XA_TCOLOR4',$colors['color4']);
        define('_XA_TCOLOR5',$colors['color5']);
        define('_XA_TCOLOR6',$colors['color6']);
        define('_XA_TCOLOR7',$colors['color7']);
        define('_XA_TCOLOR8',$colors['color8']);
        define('_XA_TSEPCOLOR',$colors['sepcolor']);
        define('_XA_TTEXT1COLOR',$colors['text1']);
        define('_XA_TTEXT2COLOR',$colors['text2']);
        define('_XA_TLINKCOLOR',$colors['link']);
        define('_XA_TVLINKCOLOR',$colors['vlink']);
        define('_XA_THOVERCOLOR',$colors['hover']);
    }

    //######################################################## dynamic css hack by antz
    $filename = $themepath.'/style/style_cfg.php';
    $stylecfg = "<?php \r\n";
    if (!empty($colors)) {
    $stylecfg .= '$background = '."'".$colors['background']."';\r\n";
    $stylecfg .= '$color1 = '."'".$colors['color1']."';\r\n";
    $stylecfg .= '$color2 = '."'".$colors['color2']."';\r\n";
    $stylecfg .= '$color3 = '."'".$colors['color3']."';\r\n";
    $stylecfg .= '$color4 = '."'".$colors['color4']."';\r\n";
    $stylecfg .= '$color5 = '."'".$colors['color5']."';\r\n";
    $stylecfg .= '$color6 = '."'".$colors['color6']."';\r\n";
    $stylecfg .= '$color7 = '."'".$colors['color7']."';\r\n";
    $stylecfg .= '$color8 = '."'".$colors['color8']."';\r\n";
    $stylecfg .= '$sepcolor = '."'".$colors['sepcolor']."';\r\n";
    $stylecfg .= '$text1 = '."'".$colors['text1']."';\r\n";
    $stylecfg .= '$text2 = '."'".$colors['text2']."';\r\n";
    $stylecfg .= '$link = '."'".$colors['link']."';\r\n";
    $stylecfg .= '$vlink = '."'".$colors['vlink']."';\r\n";
    $stylecfg .= '$hover = '."'".$colors['hover']."';\r\n";
    }
    if (!empty($configs)) {
    foreach($configs as $config) {
    $stylecfg .= "$".$config[name]." = '".$config[setting]."';\r\n";
        }
    }
    $stylecfg .= "?> \r\n";
    // Let's make sure the file exists and is writable first.
    if (is_writable($filename)) {
       // In our example we're opening $filename in append mode.
       // The file pointer is at the bottom of the file hence
       // that's where $stylecfg will go when we fwrite() it.
       if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; }
       if (!ftruncate($handle, '0')) { echo "Cannot clear file ($filename)"; exit; }
       // Write $stylecfg to our opened file.
       if (fwrite($handle, $stylecfg) === false) { echo "Cannot write to file ($filename)"; exit; }
       fclose($handle);
    } else {
       echo "The file $filename is not writable";
    }
    //######################################################## dynamic css hack by antz


    master.htm is here :

    Code

    <link rel="StyleSheet" href="<!--[$themepath]-->/style/style.php" type="text/css">
    <link rel="icon" href="<!--[$imagepath]-->/icon.png" type="image/png">
    <link rel="shortcut icon" href="<!--[$imagepath]-->/favicon.ico">
    <style type="text/css">
    @import url("<!--[$themepath]-->/style/style.php");
    </style>
    <!--[additional_header]-->
    </head>
    <body>



    Is that good or not, its work good for me.
  • Posted: 16.09.2004, 03:47
     
    phpnut
    rank:
    Developer Developer
    registered:
     October 2002
    Status:
    offline
    last visit:
    24.03.06
    Posts:
    269
    If you have clicked the Generate Configuration cache

    Xanthia reads the style.php one time and creates a cached version of the file as a CSS. If you go to color settings of a theme and choose a different color setting it will be rewritten, The only time the file is rewritten is when updates are made in the control panel of Xanthia themes.

    I think the link is removed when you click it, but I have removed the code that caused that to happen in the CVS version. If you have access to you database you can removed the variable that causes it not to be displayed, but again once you click it the variable will be set again.

    Look in
    module_vars
    Find:
    pn_modname -> Xanthia
    pn_name-> YOURTHEMENAMEthemecache

    Remove that and you should be able to regenerate the them config cahe

    --
    Larry E. Masters

Extensions Moderation

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula