简体   繁体   English

如何使我的cms可以更改tumblr等主题

[英]How to make my a cms that can change themes like tumblr

Hey guys. 大家好。 I was wondering how would I make theme options for a cms of mine like tumblr? 我想知道如何为像tumblr这样的cms我的主题设置选项? I understand how to use the code like tumblr, {description}, {text} and variables like that but how would I make a theme switcher like this in php? 我了解如何使用tumblr,{description},{text}之类的代码以及类似的变量,但是如何在php中创建这样的主题切换器呢?

Simply put a php variable in your head section. 只需将php变量放在您的头部。 Be sure to create the $userCSSchoice at the beginning of your page or you will break it all! 确保在页面的开头创建$ userCSSchoice,否则将全部破坏! Doom! 厄运!

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

Nah, seriously, I do this and it works just fine for me. 不,是的,我确实做到了,对我来说效果很好。 Then you have to create all those css stylesheets, but that's not too hard. 然后,您必须创建所有这些CSS样式表,但这并不难。

An alternative is to create your CSS page in PHP so you can pass a variable to a single sheet to determine the style. 一种替代方法是在PHP中创建CSS页面,以便您可以将变量传递给单个表单来确定样式。

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

Then your PHP/CSS page can determine colors/images.. 然后,您的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; ?>;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM