css - Dynamically update and compile SCSS with PHP on database update


I'm here for counseling as I'm currently re-designing my website to add a user-interface which will allow me to edit it's architecture and content anywhere and whenever I want.
(I know there is already CMS or Frameworks made to ease the development but I'm trying to learn the "how to" and methods of development before jumping that step.)

I designed my website stylesheet using SASS/Compass which output me a clean CSS file.

In this css I have some icons classes generated using SASS loop, they have the same attributes but the background.

$icon-list: aftereffect, photoshop, illustrator;

@each $icon in $icon-list {
    .#{$icon} {
        background-image: url("../icons/JPEG/#{$icon}.jpg");

The "$icon-list"s content which was static is now stored in a table to be dynamic, I wish to add and remove entries freely without manually editing and producing again and again.
So my question here is : How can I do to generate the icon classes only when there is an update in the icon's table ? What's the best way to do it ?

Those are the two mains solution I came with:

  • I think it's possible to compile SCSS with PHP, I could edit the icon's SCSS file, then replace the $icon-list variable's content and compile scss whenever I'd issue an add/remove request with php on the icon table. But I'm not too sure of how to do it.

  • Always when an add/remove request would be issued, I could generate the new icons classes with php and stack them to the bottom of the main stylesheet. But then I'd have to search and remove the previous classes, because It wouldn't erase the previous styles and I wish to keep only one css file.

I hope you will be able to help and counsel me on which methods are the best and if you have a better way to do it. I'm not asking for snippets of code because I really wish to develop myself and learn but If there is a need for it, to explain something then be it. I'm really sorry for seeming exigent and for my bad english as I'm not a native speaker.

Thank you.

People are also looking for solutions to the problem: php - Translate Zend Form Validation Error Messages?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.