Dynamic CSS with PHP goes against good practices?

2

Dynamic CSS with PHP goes against good practices?

I need to change the background image of the header of a page according to her article. I thought of writing CSS inside a PHP file for this, but I do not know if it is considered a good practice ... or worse, a bad piastic.

NOTE: I also thought of doing this using AJAX for as soon as the page loads, it accesses the database, picks up the image name and changes in CSS.

    
asked by anonymous 17.02.2017 / 16:05

1 answer

1

Yes, it is a bad practice if you work with Design Patterns and MVC architectures. However, if you program structured, I see no problem, but there are better ways to create a dynamic CSS, with javascript and Ajax. You can do Ajax and use Jquery events, for example:

$.ajax({
   url: "test.html",
   context: document.body
}).success(function() {
   $( this ).css( "background-color", "#00000" );
});

I hope I have helped! Any questions, we are there!

    
17.02.2017 / 16:33