duan111112 2012-04-24 08:37
浏览 37

我应该如何在PHP CMS中实现CSS样式转换器?

Background

I'm developing my own OOP content management system in PHP for fun and to expand my programmig knowledge

What I've got

I've got the main framework set up, users can login to the backend, add pages, edit pages, set up content in rows or columns, add logo's, billboards, etc.

Expantion

My next venture is to allow users to modify the style of their website through the panel. including header colours, font size, font family, etc

How to Implement

I thought of a number of ways to do this, but i wanted to ask the community to see if they can come up with a better solution or justify one of my solutions.

Idea 1:

I could write/find a php class that parses a css style sheet, and then re-writes it as the new style sheet with the editted values

Idea 2:

I could separate the existing style sheet into structure, colors, fonts, etc, and just allow the user to modify the colors and fots separately.

Idea 3:

I could ditch the whole separating style from content idea, and make php to write the user specified styles right into the html...

Information

Does anybody have any other methods they could think of?

If not which one of mine would work best/be most efficient/optimal etc

This is not a discussion, I'm asking a specific programming question.

I understand that the panel must have an interface for the user to change the values and save their configuration in a Database OR save their configuration directly in the new css file.

I'm just not sure which way would be the "best" way.

How would 'you' do it?

  • 写回答

1条回答 默认 最新

  • dousou3027 2012-05-03 18:14
    关注

    I would change the stylesheets with JavaScript, like:

    <link rel="stylesheet" href="somestyle.css" id="stylesheet">
    
    function changeStyle(cssfile) {
      document.getElementById('stylesheet').href = cssfile;
    }
    

    I also would enter the user's selections via AJAX into the database, so when PHP creates the next page, it knows which styles the user has selected.

    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式