大家好。我想知道如何为我的 tumblr 之类的 cms 制作主题选项?我了解如何使用 tumblr、{description}、{text} 之类的代码和类似的变量,但我如何在 php 中制作这样的主题切换器?
问问题
322 次
2 回答
2
只需在 head 部分中放置一个 php 变量。一定要在页面的开头创建 $userCSSchoice 否则你会破坏它!厄运!
<LINK REL=StyleSheet HREF="<?php echo $userCSSchoice; ?>.css" TYPE="text/css" MEDIA=screen>
不,说真的,我这样做了,对我来说效果很好。然后您必须创建所有这些 css 样式表,但这并不难。
于 2010-12-22T21:32:28.150 回答
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; ?>;
}
于 2010-12-22T21:38:11.130 回答