如何让我的cms可以改变像tumblr这样的主题

时间:2010-12-22 21:26:14

标签: php tumblr

嘿伙计们。我想知道如何为像tumblr这样的cms做主题选项?我理解如何使用像tumblr,{description},{text}这样的代码和类似的变量,但是如何在php中创建这样的主题切换器?

2 个答案:

答案 0 :(得分:2)

只需在头部添加一个php变量即可。一定要在页面的开头创建$ userCSSchoice,否则你就会破坏它们!末日!

<LINK REL=StyleSheet HREF="<?php echo $userCSSchoice; ?>.css" TYPE="text/css" MEDIA=screen>

不,说真的,我这样做,对我来说效果很好。然后你必须创建所有那些css样式表,但这不是太难。

答案 1 :(得分:1)

另一种方法是在PHP中创建CSS页面,这样您就可以将变量传递给单个工作表来确定样式。

<link rel=StyleSheet href="styles.php?theme=<?php echo $userCSSchoice; ?>" type="text/css" media=screen>

然后您的PHP / CSS页面可以确定颜色/图像..

<?php
    header("Content-Type: text/css");

    if (isset($_REQUEST['theme']))
        $theme = $_REQUEST['theme'];
    else
        $theme="default";

    $bgImage="images/bg_".$theme.".png";    

    if ($theme=="default")
        $mainColor="0f8200";
    else if ($theme=="green")
        $mainColor="009900";

?>

body {
    background:url('<?php echo $bgImage; ?>')  repeat-x #<?php echo $bg; ?>;
    color: #<?php echo $mainColor; ?>;
}
相关问题