dongtui9168 2014-02-17 13:15
浏览 27

使用php为单个页面选择唯一的样式表

My question is: is it possible to have different stylesheets on the same website? I’m already aware that its possible to link several stylesheets to each other but that isn’t quite what I’m looking for. My goal is to make it possible for a logged in administrator to edit a stylesheet that only affects the look of the start page.

The website uses php for connecting the pages to one another and the links to the stylesheets are located in the header.php document:

<?php if(isset($_SESSION['stylesheet'])): ?>

<link rel="stylesheet" href="style/<?php echo $_SESSION['stylesheet']; ?>"> 

<?php else: ?>

<link rel="stylesheet" href="style/stylesheet.css" title="General stylesheet">

<?php endif; ?>

Would it be possible to modify this code so that an alternative stylesheet controls the look of the front page exclusively?

  • 写回答

1条回答 默认 最新

  • douweng9427 2014-03-30 06:50
    关注

    According to your comment that the start page has a variable $pageId with the value hem you can include a stylesheet exclusively to the start page by adding

    if($pageId == "hem") {
        echo '<link rel="stylesheet" href="path/to/stylesheet/for/startpage.css">';
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题